#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 */
char *concat(char *, char *);
char *gen_cond_goto(char *, char *);
char *gen_goto(char *);
char *newlabel();
char *gen_if(char *expr_code, char *expr, char *if_statements,
             char *else_statements) {
  char *result = expr_code;
  char *label1 = newlabel();
  char *label2 = newlabel();
  result = concat(result, gen_cond_goto(label1, expr));
  result = concat(result, else_statements);
  result = concat(result, gen_goto(label2));
  result = concat(result, concat(label1, ":\n"));
  result = concat(result, if_statements);
  result = concat(result, concat(label2, ":\n"));
  return result;
}


x86 assembly (clang, -O0):
<gen_if>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1040 <newlabel@plt>
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1040 <newlabel@plt>
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <gen_cond_goto@plt>
mov    -0x58(%rbp),%rdi
mov    %rax,%rsi
call   1050 <concat@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <concat@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x38(%rbp),%rdi
call   1060 <gen_goto@plt>
mov    -0x50(%rbp),%rdi
mov    %rax,%rsi
call   1050 <concat@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xe20(%rip),%rsi
call   1050 <concat@plt>
mov    -0x48(%rbp),%rdi
mov    %rax,%rsi
call   1050 <concat@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <concat@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xde7(%rip),%rsi
call   1050 <concat@plt>
mov    -0x40(%rbp),%rdi
mov    %rax,%rsi
call   1050 <concat@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_if>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%rbp
xor    %eax,%eax
call   1040 <newlabel@plt>
mov    %rax,%r13
xor    %eax,%eax
call   1040 <newlabel@plt>
mov    %rax,%r15
mov    %r13,%rdi
mov    %rbx,%rsi
call   1030 <gen_cond_goto@plt>
mov    %rbp,%rdi
mov    %rax,%rsi
call   1050 <concat@plt>
mov    %rax,%rdi
mov    %r12,%rsi
call   1050 <concat@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1060 <gen_goto@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <concat@plt>
mov    %rax,%rbx
lea    0xe54(%rip),%rbp
mov    %r13,%rdi
mov    %rbp,%rsi
call   1050 <concat@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <concat@plt>
mov    %rax,%rdi
mov    %r14,%rsi
call   1050 <concat@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rbp,%rsi
call   1050 <concat@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <concat@plt>

LLVM IR (-O0):
@.str = [3 x i8] c":\0A\00"
define i8* @gen_if(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%12 = load i8*, i8** %5
store i8* %12, i8** %9
%13 = call i8* (...) @newlabel()
store i8* %13, i8** %10
%14 = call i8* (...) @newlabel()
store i8* %14, i8** %11
%15 = load i8*, i8** %9
%16 = load i8*, i8** %10
%17 = load i8*, i8** %6
%18 = call i8* @gen_cond_goto(i8* %16, i8* %17)
%19 = call i8* @concat(i8* %15, i8* %18)
store i8* %19, i8** %9
%20 = load i8*, i8** %9
%21 = load i8*, i8** %8
%22 = call i8* @concat(i8* %20, i8* %21)
store i8* %22, i8** %9
%23 = load i8*, i8** %9
%24 = load i8*, i8** %11
%25 = call i8* @gen_goto(i8* %24)
%26 = call i8* @concat(i8* %23, i8* %25)
store i8* %26, i8** %9
%27 = load i8*, i8** %9
%28 = load i8*, i8** %10
%29 = call i8* @concat(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%30 = call i8* @concat(i8* %27, i8* %29)
store i8* %30, i8** %9
%31 = load i8*, i8** %9
%32 = load i8*, i8** %7
%33 = call i8* @concat(i8* %31, i8* %32)
store i8* %33, i8** %9
%34 = load i8*, i8** %9
%35 = load i8*, i8** %11
%36 = call i8* @concat(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%37 = call i8* @concat(i8* %34, i8* %36)
store i8* %37, i8** %9
%38 = load i8*, i8** %9
ret i8* %38
}

LLVM IR (-O2):
@.str = [3 x i8] c":\0A\00"
define i8* @gen_if(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = tail call i8* (...) @newlabel()
%6 = tail call i8* (...) @newlabel()
%7 = tail call i8* @gen_cond_goto(i8* %5, i8* %1)
%8 = tail call i8* @concat(i8* %0, i8* %7)
%9 = tail call i8* @concat(i8* %8, i8* %3)
%10 = tail call i8* @gen_goto(i8* %6)
%11 = tail call i8* @concat(i8* %9, i8* %10)
%12 = tail call i8* @concat(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = tail call i8* @concat(i8* %11, i8* %12)
%14 = tail call i8* @concat(i8* %13, i8* %2)
%15 = tail call i8* @concat(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%16 = tail call i8* @concat(i8* %14, i8* %15)
ret i8* %16
}