#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 */

/* Variables and functions */
scalar_t__ strcmp(char const *, char *);
int read_bool(int *out, const char *in) {
  if (strcmp(in, "true") == 0 || strcmp(in, "TRUE") == 0 ||
      strcmp(in, "1") == 0)
    *out = 1;
  else if (strcmp(in, "false") == 0 || strcmp(in, "FALSE") == 0 ||
           strcmp(in, "0") == 0)
    *out = 0;
  else
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<read_bool>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xed5(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     116e <read_bool+0x5e>
mov    -0x18(%rbp),%rdi
lea    0xec0(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     116e <read_bool+0x5e>
mov    -0x18(%rbp),%rdi
lea    0xeab(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    117d <read_bool+0x6d>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
jmp    11eb <read_bool+0xdb>
mov    -0x18(%rbp),%rdi
lea    0xe84(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     11cb <read_bool+0xbb>
mov    -0x18(%rbp),%rdi
lea    0xe70(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     11cb <read_bool+0xbb>
mov    -0x18(%rbp),%rdi
lea    0xe5c(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11da <read_bool+0xca>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
jmp    11e6 <read_bool+0xd6>
movl   $0x1,-0x4(%rbp)
jmp    11f2 <read_bool+0xe2>
jmp    11eb <read_bool+0xdb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_bool>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xedf(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     11a1 <read_bool+0x91>
lea    0xecb(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11a1 <read_bool+0x91>
lea    0xebc(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11a1 <read_bool+0x91>
lea    0xeaa(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     11a1 <read_bool+0x91>
lea    0xe9a(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11a1 <read_bool+0x91>
lea    0xe8c(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    11a6 <read_bool+0x96>
mov    %ebp,(%r14)
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"true\00"
@.str.1 = [5 x i8] c"TRUE\00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [6 x i8] c"false\00"
@.str.4 = [6 x i8] c"FALSE\00"
@.str.5 = [2 x i8] c"0\00"
define i32 @read_bool(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
store i32* %0, i32** %4
store i8* %1, i8** %5
%6 = load i8*, i8** %5
%7 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %17, label %9
9: ; preds = %2
%10 = load i8*, i8** %5
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %17, label %13
13: ; preds = %9
%14 = load i8*, i8** %5
%15 = call i64 @strcmp(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %13, %9, %2
%18 = load i32*, i32** %4
store i32 1, i32* %18
br label %35
19: ; preds = %13
%20 = load i8*, i8** %5
%21 = call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %31, label %23
23: ; preds = %19
%24 = load i8*, i8** %5
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %31, label %27
27: ; preds = %23
%28 = load i8*, i8** %5
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %27, %23, %19
%32 = load i32*, i32** %4
store i32 0, i32* %32
br label %34
33: ; preds = %27
store i32 1, i32* %3
br label %36
34: ; preds = %31
br label %35
35: ; preds = %34, %17
store i32 0, i32* %3
br label %36
36: ; preds = %35, %33
%37 = load i32, i32* %3
ret i32 %37
}

LLVM IR (-O2):
@.str = [5 x i8] c"true\00"
@.str.1 = [5 x i8] c"TRUE\00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [6 x i8] c"false\00"
@.str.4 = [6 x i8] c"FALSE\00"
@.str.5 = [2 x i8] c"0\00"
define i32 @read_bool(i32* nocapture writeonly %0, i8* %1) {
%3 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %20, label %5
5: ; preds = %2
%6 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %20, label %8
8: ; preds = %5
%9 = tail call i64 @strcmp(i8* %1, 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 %20, label %11
11: ; preds = %8
%12 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %20, label %14
14: ; preds = %11
%15 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %14
%18 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %11, %14, %17, %2, %5, %8
%21 = phi i32 [ 1, %8 ], [ 1, %5 ], [ 1, %2 ], [ 0, %17 ], [ 0, %14 ], [ 0, %11 ]
store i32 %21, i32* %0
br label %22
22: ; preds = %17, %20
%23 = phi i32 [ 0, %20 ], [ 1, %17 ]
ret i32 %23
}