#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct mibinfo {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ strlcpy(char *, char *, size_t);
int bool_format(struct mibinfo *m, const void *data, size_t data_size,
                char *buf, size_t len) {
  const unsigned char *p;
  int f = 0;
  for (p = data; p < (const unsigned char *)data + data_size; p++)
    if (*p != 0) {
      f = 1;
      break;
    }
  if (f)
    strlcpy(buf, "on", len);
  else
    strlcpy(buf, "off", len);
  return 0;
}


x86 assembly (clang, -O0):
<bool_format>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x10(%rbp),%rcx
add    -0x18(%rbp),%rcx
cmp    %rcx,%rax
jae    1182 <bool_format+0x72>
mov    -0x30(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
je     116c <bool_format+0x5c>
movl   $0x1,-0x34(%rbp)
jmp    1182 <bool_format+0x72>
jmp    1171 <bool_format+0x61>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    113b <bool_format+0x2b>
cmpl   $0x0,-0x34(%rbp)
je     11a5 <bool_format+0x95>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xe65(%rip),%rsi
call   1030 <strlcpy@plt>
jmp    11b9 <bool_format+0xa9>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xe4f(%rip),%rsi
call   1030 <strlcpy@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bool_format>:
push   %rax
mov    %rsi,%rax
lea    0xee8(%rip),%rsi
test   %rdx,%rdx
jle    1143 <bool_format+0x33>
add    %rax,%rdx
lea    0xed6(%rip),%rdi
nopw   0x0(%rax,%rax,1)
cmpb   $0x0,(%rax)
jne    1140 <bool_format+0x30>
add    $0x1,%rax
cmp    %rdx,%rax
jb     1130 <bool_format+0x20>
jmp    1143 <bool_format+0x33>
mov    %rdi,%rsi
mov    %rcx,%rdi
mov    %r8,%rdx
call   1030 <strlcpy@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.mibinfo = type { i32 }
@.str = [3 x i8] c"on\00"
@.str.1 = [4 x i8] c"off\00"
define i32 @bool_format(%struct.mibinfo* %0, i8* %1, i64 %2, i8* %3, i64 %4) {
%6 = alloca %struct.mibinfo*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i32
store %struct.mibinfo* %0, %struct.mibinfo** %6
store i8* %1, i8** %7
store i64 %2, i64* %8
store i8* %3, i8** %9
store i64 %4, i64* %10
store i32 0, i32* %12
%13 = load i8*, i8** %7
store i8* %13, i8** %11
br label %14
14: ; preds = %27, %5
%15 = load i8*, i8** %11
%16 = load i8*, i8** %7
%17 = load i64, i64* %8
%18 = getelementptr inbounds i8, i8* %16, i64 %17
%19 = icmp ult i8* %15, %18
br i1 %19, label %20, label %30
20: ; preds = %14
%21 = load i8*, i8** %11
%22 = load i8, i8* %21
%23 = zext i8 %22 to i32
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %20
store i32 1, i32* %12
br label %30
26: ; preds = %20
br label %27
27: ; preds = %26
%28 = load i8*, i8** %11
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %11
br label %14
30: ; preds = %25, %14
%31 = load i32, i32* %12
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = load i8*, i8** %9
%35 = load i64, i64* %10
%36 = call i32 @strlcpy(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 %35)
br label %41
37: ; preds = %30
%38 = load i8*, i8** %9
%39 = load i64, i64* %10
%40 = call i32 @strlcpy(i8* %38, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i64 %39)
br label %41
41: ; preds = %37, %33
ret i32 0
}

LLVM IR (-O2):
%struct.mibinfo = type { i32 }
@.str = [3 x i8] c"on\00"
@.str.1 = [4 x i8] c"off\00"
define i32 @bool_format(%struct.mibinfo* nocapture readnone %0, i8* %1, i64 %2, i8* %3, i64 %4) {
%6 = getelementptr inbounds i8, i8* %1, i64 %2
%7 = icmp sgt i64 %2, 0
br i1 %7, label %10, label %15
8: ; preds = %10
%9 = icmp ult i8* %14, %6
br i1 %9, label %10, label %15
10: ; preds = %5, %8
%11 = phi i8* [ %14, %8 ], [ %1, %5 ]
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
%14 = getelementptr inbounds i8, i8* %11, i64 1
br i1 %13, label %8, label %15
15: ; preds = %8, %10, %5
%16 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %5 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %10 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %8 ]
%17 = tail call i32 @strlcpy(i8* %3, i8* %16, i64 %4)
ret i32 0
}