true_or_false(src) char *src;
{
  char *str;
  char *pt;
  int v;
  str = strdup(src);
  for (pt = str; *pt; pt++)
    *pt = tolower(*pt);
  v = -1;
  if (strcmp(str, "true") == 0)
    v = 1;
  else if (strcmp(str, "false") == 0)
    v = 0;
  else if (strcmp(str, "1") == 0)
    v = 1;
  else if (strcmp(str, "0") == 0)
    v = 0;
  free(str);
  return (v);
}


x86 assembly (clang, -O0):
<true_or_false>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1193 <true_or_false+0x53>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1050 <tolower@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1161 <true_or_false+0x21>
movl   $0xffffffff,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe5b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11bf <true_or_false+0x7f>
movl   $0x1,-0x1c(%rbp)
jmp    1238 <true_or_false+0xf8>
mov    -0x10(%rbp),%rdi
lea    0xe3b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11e4 <true_or_false+0xa4>
movl   $0x0,-0x1c(%rbp)
jmp    1233 <true_or_false+0xf3>
mov    -0x10(%rbp),%rdi
lea    0xe1c(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1209 <true_or_false+0xc9>
movl   $0x1,-0x1c(%rbp)
jmp    122e <true_or_false+0xee>
mov    -0x10(%rbp),%rdi
lea    0xdf9(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1229 <true_or_false+0xe9>
movl   $0x0,-0x1c(%rbp)
jmp    122e <true_or_false+0xee>
jmp    1233 <true_or_false+0xf3>
jmp    1238 <true_or_false+0xf8>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<true_or_false>:
push   %rbp
push   %rbx
push   %rax
call   1060 <strdup@plt>
mov    %rax,%rbp
mov    (%rax),%al
test   %al,%al
je     1176 <true_or_false+0x36>
mov    %rbp,%rbx
add    $0x1,%rbx
nopl   0x0(%rax,%rax,1)
movsbl %al,%edi
call   1050 <tolower@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1160 <true_or_false+0x20>
lea    0xe83(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strcmp@plt>
mov    $0x1,%ebx
test   %eax,%eax
je     11cb <true_or_false+0x8b>
lea    0xe70(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11c9 <true_or_false+0x89>
lea    0xe63(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11cb <true_or_false+0x8b>
lea    0xe52(%rip),%rsi
mov    %rbp,%rdi
call   1040 <strcmp@plt>
neg    %eax
sbb    %ebx,%ebx
jmp    11cb <true_or_false+0x8b>
xor    %ebx,%ebx
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"true\00"
@.str.1 = [6 x i8] c"false\00"
@.str.2 = [2 x i8] c"1\00"
@.str.3 = [2 x i8] c"0\00"
define i32 @true_or_false(i8* nocapture %0) {
%2 = tail call i8* @strdup(i8* %0)
%3 = load i8, i8* %2
%4 = icmp eq i8 %3, 0
br i1 %4, label %14, label %5
5: ; preds = %1, %5
%6 = phi i8 [ %12, %5 ], [ %3, %1 ]
%7 = phi i8* [ %11, %5 ], [ %2, %1 ]
%8 = sext i8 %6 to i32
%9 = tail call i32 @tolower(i32 %8)
%10 = trunc i32 %9 to i8
store i8 %10, i8* %7
%11 = getelementptr inbounds i8, i8* %7, i64 1
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 0
br i1 %13, label %14, label %5
14: ; preds = %5, %1
%15 = tail call i32 @strcmp(i8* dereferenceable(1) %2, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i32 %15, 0
br i1 %16, label %27, label %17
17: ; preds = %14
%18 = tail call i32 @strcmp(i8* dereferenceable(1) %2, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %27, label %20
20: ; preds = %17
%21 = tail call i32 @strcmp(i8* dereferenceable(1) %2, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i32 %21, 0
br i1 %22, label %27, label %23
23: ; preds = %20
%24 = tail call i32 @strcmp(i8* dereferenceable(1) %2, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%25 = icmp ne i32 %24, 0
%26 = sext i1 %25 to i32
br label %27
27: ; preds = %23, %20, %17, %14
%28 = phi i32 [ 1, %14 ], [ 0, %17 ], [ 1, %20 ], [ %26, %23 ]
tail call void @free(i8* %2)
ret i32 %28
}