#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 *, char *);
scalar_t__ strncmp(char *, char *, int);
char tolower(char);
int getbool(char *value) {
  int num;
  for (num = 0; value[num] != 0; num++)
    value[num] = tolower(value[num]);
  if (strncmp(value, "y", 1) == 0)
    return 1;
  if (strcmp(value, "true") == 0)
    return 1;
  if (strcmp(value, "on") == 0)
    return 1;
  if (strcmp(value, "1") == 0)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<getbool>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1184 <getbool+0x54>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <tolower@plt>
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1143 <getbool+0x13>
mov    -0x10(%rbp),%rdi
lea    0xe71(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11af <getbool+0x7f>
movl   $0x1,-0x4(%rbp)
jmp    1228 <getbool+0xf8>
mov    -0x10(%rbp),%rdi
lea    0xe48(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11d5 <getbool+0xa5>
movl   $0x1,-0x4(%rbp)
jmp    1228 <getbool+0xf8>
mov    -0x10(%rbp),%rdi
lea    0xe27(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11fb <getbool+0xcb>
movl   $0x1,-0x4(%rbp)
jmp    1228 <getbool+0xf8>
mov    -0x10(%rbp),%rdi
lea    0xe04(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1221 <getbool+0xf1>
movl   $0x1,-0x4(%rbp)
jmp    1228 <getbool+0xf8>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getbool>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%al
test   %al,%al
je     1157 <getbool+0x27>
lea    0x1(%rbx),%rbp
movsbl %al,%edi
call   1050 <tolower@plt>
mov    %al,-0x1(%rbp)
movzbl 0x0(%rbp),%eax
add    $0x1,%rbp
test   %al,%al
jne    1140 <getbool+0x10>
lea    0xea2(%rip),%rsi
mov    $0x1,%ebp
mov    %rbx,%rdi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11b5 <getbool+0x85>
lea    0xe86(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11b5 <getbool+0x85>
lea    0xe77(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11b5 <getbool+0x85>
lea    0xe66(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
sete   %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"y\00"
@.str.1 = [5 x i8] c"true\00"
@.str.2 = [3 x i8] c"on\00"
@.str.3 = [2 x i8] c"1\00"
define i32 @getbool(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
br label %5
5: ; preds = %24, %1
%6 = load i8*, i8** %3
%7 = load i32, i32* %4
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %6, i64 %8
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %27
13: ; preds = %5
%14 = load i8*, i8** %3
%15 = load i32, i32* %4
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = call signext i8 @tolower(i8 signext %18)
%20 = load i8*, i8** %3
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
store i8 %19, i8* %23
br label %24
24: ; preds = %13
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %5
27: ; preds = %5
%28 = load i8*, i8** %3
%29 = call i64 @strncmp(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %27
store i32 1, i32* %2
br label %48
32: ; preds = %27
%33 = load i8*, i8** %3
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %32
store i32 1, i32* %2
br label %48
37: ; preds = %32
%38 = load i8*, i8** %3
%39 = call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %37
store i32 1, i32* %2
br label %48
42: ; preds = %37
%43 = load i8*, i8** %3
%44 = call i64 @strcmp(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %42
store i32 1, i32* %2
br label %48
47: ; preds = %42
store i32 0, i32* %2
br label %48
48: ; preds = %47, %46, %41, %36, %31
%49 = load i32, i32* %2
ret i32 %49
}

LLVM IR (-O2):
@.str = [2 x i8] c"y\00"
@.str.1 = [5 x i8] c"true\00"
@.str.2 = [3 x i8] c"on\00"
@.str.3 = [2 x i8] c"1\00"
define i32 @getbool(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %13, label %4
4: ; preds = %1, %4
%5 = phi i64 [ %9, %4 ], [ 0, %1 ]
%6 = phi i8 [ %11, %4 ], [ %2, %1 ]
%7 = phi i8* [ %10, %4 ], [ %0, %1 ]
%8 = tail call signext i8 @tolower(i8 signext %6)
store i8 %8, i8* %7
%9 = add nuw i64 %5, 1
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %13, label %4
13: ; preds = %4, %1
%14 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%15 = icmp eq i64 %14, 0
br i1 %15, label %26, label %16
16: ; preds = %13
%17 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %26, label %19
19: ; preds = %16
%20 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %19
%23 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
%25 = zext i1 %24 to i32
br label %26
26: ; preds = %22, %19, %16, %13
%27 = phi i32 [ 1, %13 ], [ 1, %16 ], [ 1, %19 ], [ %25, %22 ]
ret i32 %27
}