#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 */
typedef int ssize_t;

/* Variables and functions */
scalar_t__ strcmp(char const *, char *);
ssize_t parse_boolean(const char *buffer, const char **error) {
  if (strcmp(buffer, "on") == 0)
    return 1;
  if (strcmp(buffer, "off") == 0)
    return 1;
  if (strcmp(buffer, "1") == 0)
    return 1;
  if (strcmp(buffer, "0") == 0)
    return 1;
  *error = "Invalid value for boolean";
  return 0;
}


x86 assembly (clang, -O0):
<parse_boolean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed5(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1146 <parse_boolean+0x36>
movl   $0x1,-0x4(%rbp)
jmp    11cd <parse_boolean+0xbd>
mov    -0x10(%rbp),%rdi
lea    0xeb2(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    116c <parse_boolean+0x5c>
movl   $0x1,-0x4(%rbp)
jmp    11cd <parse_boolean+0xbd>
mov    -0x10(%rbp),%rdi
lea    0xe90(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    1192 <parse_boolean+0x82>
movl   $0x1,-0x4(%rbp)
jmp    11cd <parse_boolean+0xbd>
mov    -0x10(%rbp),%rdi
lea    0xe6c(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11b8 <parse_boolean+0xa8>
movl   $0x1,-0x4(%rbp)
jmp    11cd <parse_boolean+0xbd>
mov    -0x18(%rbp),%rax
lea    0xe48(%rip),%rcx
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_boolean>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xedf(%rip),%rsi
call   1030 <strcmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     1178 <parse_boolean+0x68>
lea    0xecc(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1178 <parse_boolean+0x68>
lea    0xebc(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1178 <parse_boolean+0x68>
lea    0xeaa(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1178 <parse_boolean+0x68>
lea    0xe98(%rip),%rax
mov    %rax,(%r14)
xor    %ebp,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"on\00"
@.str.1 = [4 x i8] c"off\00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [2 x i8] c"0\00"
@.str.4 = [26 x i8] c"Invalid value for boolean\00"
define i32 @parse_boolean(i8* %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8**
store i8* %0, i8** %4
store i8** %1, i8*** %5
%6 = load i8*, i8** %4
%7 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %2
store i32 1, i32* %3
br label %27
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %10
store i32 1, i32* %3
br label %27
15: ; preds = %10
%16 = load i8*, i8** %4
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15
store i32 1, i32* %3
br label %27
20: ; preds = %15
%21 = load i8*, i8** %4
%22 = call i64 @strcmp(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 1, i32* %3
br label %27
25: ; preds = %20
%26 = load i8**, i8*** %5
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8** %26
store i32 0, i32* %3
br label %27
27: ; preds = %25, %24, %19, %14, %9
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@.str = [3 x i8] c"on\00"
@.str.1 = [4 x i8] c"off\00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [2 x i8] c"0\00"
@.str.4 = [26 x i8] c"Invalid value for boolean\00"
define i32 @parse_boolean(i8* %0, i8** nocapture writeonly %1) {
%3 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %15, label %5
5: ; preds = %2
%6 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %5
%9 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %8
%12 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %11
store i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8** %1
br label %15
15: ; preds = %11, %8, %5, %2, %14
%16 = phi i32 [ 0, %14 ], [ 1, %2 ], [ 1, %5 ], [ 1, %8 ], [ 1, %11 ]
ret i32 %16
}