#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__ IsIt42(int);
int StringLen(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  char test[20] = "Do. Or do not.";
  printf("String has length: %d\n", StringLen(test));
  int theAnswer = 21;
  if (IsIt42(theAnswer)) {
    printf("The answer is 42.\n");
  } else {
    printf("What? That can't be right...\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb5(%rip),%eax
mov    %eax,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
call   1050 <StringLen@plt>
mov    %eax,%esi
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x15,-0x24(%rbp)
mov    -0x24(%rbp),%edi
call   1040 <IsIt42@plt>
cmp    $0x0,%rax
je     11a3 <main+0x73>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b1 <main+0x81>
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movaps 0xeb5(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
mov    %rsp,%rdi
call   1060 <StringLen@plt>
lea    0xeae(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x15,%edi
call   1050 <IsIt42@plt>
test   %rax,%rax
lea    0xea8(%rip),%rax
lea    0xebe(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.main.test = [20 x i8] c"Do. Or do not.\00\00\00\00\00\00"
@.str = [23 x i8] c"String has length: %d\0A\00"
@.str.1 = [19 x i8] c"The answer is 42.\0A\00"
@.str.2 = [30 x i8] c"What? That can't be right...\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = bitcast [20 x i8]* %2 to i8*
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%6 = call i32 @StringLen(i8* %5)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %6)
store i32 21, i32* %3
%8 = load i32, i32* %3
%9 = call i64 @IsIt42(i32 %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %15
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %13, %11
ret i32 0
}

LLVM IR (-O2):
@__const.main.test = [20 x i8] c"Do. Or do not.\00\00\00\00\00\00"
@.str = [23 x i8] c"String has length: %d\0A\00"
@str = [29 x i8] c"What? That can't be right...\00"
@str.3 = [18 x i8] c"The answer is 42.\00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%3 = call i32 @StringLen(i8* %2)
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = call i64 @IsIt42(i32 21)
%6 = icmp eq i64 %5, 0
%7 = select i1 %6, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @str.3, i64 0, i64 0)
%8 = call i32 @puts(i8* dereferenceable(1) %7)
ret i32 0
}