#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 */
unsigned int findAllSideEffects(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
char *readFile(char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  char *z;
  unsigned int nErr = 0;
  if (argc != 2) {
    fprintf(stderr, "Usage: %s FILENAME\n", argv[0]);
    return 1;
  }
  z = readFile(argv[1]);
  nErr = findAllSideEffects(z);
  free(z);
  if (nErr) {
    fprintf(stderr, "Found %u undesirable side-effects\n", nErr);
    return 1;
  }
  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)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1191 <main+0x51>
mov    0x2e72(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe82(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11ee <main+0xae>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <readFile@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <findAllSideEffects@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <free@plt>
cmpl   $0x0,-0x1c(%rbp)
je     11e7 <main+0xa7>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
mov    -0x1c(%rbp),%edx
lea    0xe40(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11ee <main+0xae>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    1185 <main+0x45>
mov    0x8(%rsi),%rdi
call   1060 <readFile@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <findAllSideEffects@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <free@plt>
test   %ebp,%ebp
je     11a6 <main+0x66>
mov    0x2e6f(%rip),%rax
mov    (%rax),%edi
lea    0xe9a(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    119f <main+0x5f>
mov    0x2e54(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe68(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%eax
jmp    11a8 <main+0x68>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"Usage: %s FILENAME\0A\00"
@.str.1 = [35 x i8] c"Found %u undesirable side-effects\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 1, i32* %3
br label %32
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i8* @readFile(i8* %19)
store i8* %20, i8** %6
%21 = load i8*, i8** %6
%22 = call i32 @findAllSideEffects(i8* %21)
store i32 %22, i32* %7
%23 = load i8*, i8** %6
%24 = call i32 @free(i8* %23)
%25 = load i32, i32* %7
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %16
%28 = load i32, i32* @stderr
%29 = load i32, i32* %7
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %29)
store i32 1, i32* %3
br label %32
31: ; preds = %16
store i32 0, i32* %3
br label %32
32: ; preds = %31, %27, %10
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"Usage: %s FILENAME\0A\00"
@.str.1 = [35 x i8] c"Found %u undesirable side-effects\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %18
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i8* @readFile(i8* %10)
%12 = tail call i32 @findAllSideEffects(i8* %11)
%13 = tail call i32 @free(i8* %11)
%14 = icmp eq i32 %12, 0
br i1 %14, label %18, label %15
15: ; preds = %8
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %12)
br label %18
18: ; preds = %8, %15, %4
%19 = phi i32 [ 1, %4 ], [ 1, %15 ], [ 0, %8 ]
ret i32 %19
}