#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 */
int /*<<< orphan*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ test1(char *);
int /*<<< orphan*/ test2(char *);
int /*<<< orphan*/ test3(char *);
int main(int argc, char **argv) {
  char *array = (char *)malloc(10);
  if (argc != 2)
    return 1;
  if (!strcmp(argv[1], "test1"))
    test1(array);
  if (!strcmp(argv[1], "test2"))
    test2(array);
  if (!strcmp(argv[1], "test3"))
    test3(array);
  free(array);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0xa,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     119a <main+0x3a>
movl   $0x1,-0x4(%rbp)
jmp    121c <main+0xbc>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe57(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11c0 <main+0x60>
mov    -0x18(%rbp),%rdi
call   1050 <test1@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe37(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11e6 <main+0x86>
mov    -0x18(%rbp),%rdi
call   1080 <test2@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe17(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    120c <main+0xac>
mov    -0x18(%rbp),%rdi
call   1040 <test3@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %edi,%ebx
mov    $0xa,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
mov    $0x1,%eax
cmp    $0x2,%ebx
jne    11e8 <main+0x88>
mov    0x8(%r15),%rbx
lea    0xe74(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    11a4 <main+0x44>
mov    %r14,%rdi
call   1050 <test1@plt>
mov    0x8(%r15),%rbx
lea    0xe5b(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    11c3 <main+0x63>
mov    %r14,%rdi
call   1080 <test2@plt>
mov    0x8(%r15),%rbx
lea    0xe42(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    11de <main+0x7e>
mov    %r14,%rdi
call   1040 <test3@plt>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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