#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ display_trace(char const *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ *stdin;
int main(int argc, char **argv) {
  int status = 0;
  const char *filename;
  FILE *fp;
  if (argc == 1)
    display_trace("<stdin>", stdin);
  else {
    while (--argc) {
      filename = *++argv;
      if ((fp = fopen(filename, "rb"))) {
        display_trace(filename, fp);
        fclose(fp);
      } else {
        fprintf(stderr, "disptrace: unable to open %s: %m\n", filename);
        status++;
      }
    }
  }
  return status;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1182 <main+0x42>
mov    0x2e7a(%rip),%rax
mov    (%rax),%rsi
lea    0xe88(%rip),%rdi
call   1050 <display_trace@plt>
jmp    1215 <main+0xd5>
jmp    1187 <main+0x47>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
je     1210 <main+0xd0>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe4d(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
je     11e9 <main+0xa9>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <display_trace@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
jmp    120b <main+0xcb>
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe0e(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1187 <main+0x47>
jmp    1215 <main+0xd5>
mov    -0x14(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x1,%edi
jne    117b <main+0x3b>
mov    0x2e91(%rip),%rax
mov    (%rax),%rsi
lea    0xe9f(%rip),%rdi
call   1050 <display_trace@plt>
xor    %r12d,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsi,%r13
mov    %edi,%r15d
xor    %r12d,%r12d
mov    $0x1,%r14d
jmp    11b5 <main+0x75>
nopl   0x0(%rax)
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
lea    0xe6b(%rip),%rsi
mov    %rbp,%rdx
call   1040 <fprintf@plt>
add    $0x1,%r12d
add    $0x1,%r14
cmp    %r14d,%r15d
je     1169 <main+0x29>
mov    0x0(%r13,%r14,8),%rbp
mov    %rbp,%rdi
lea    0xe44(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1190 <main+0x50>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    %rax,%rsi
call   1050 <display_trace@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
jmp    11ac <main+0x6c>

LLVM IR (-O0):
@.str = [8 x i8] c"<stdin>\00"
@stdin = global i32* null
@.str.1 = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.2 = [34 x i8] c"disptrace: unable to open %s: %m\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32*, i32** @stdin
%13 = call i32 @display_trace(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* %12)
br label %40
14: ; preds = %2
br label %15
15: ; preds = %38, %14
%16 = load i32, i32* %4
%17 = add nsw i32 %16, -1
store i32 %17, i32* %4
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %39
19: ; preds = %15
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i32 1
store i8** %21, i8*** %5
%22 = load i8*, i8** %21
store i8* %22, i8** %7
%23 = load i8*, i8** %7
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %24, i32** %8
%25 = icmp ne i32* %24, null
br i1 %25, label %26, label %32
26: ; preds = %19
%27 = load i8*, i8** %7
%28 = load i32*, i32** %8
%29 = call i32 @display_trace(i8* %27, i32* %28)
%30 = load i32*, i32** %8
%31 = call i32 @fclose(i32* %30)
br label %38
32: ; preds = %19
%33 = load i32, i32* @stderr
%34 = load i8*, i8** %7
%35 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %34)
%36 = load i32, i32* %6
%37 = add nsw i32 %36, 1
store i32 %37, i32* %6
br label %38
38: ; preds = %32, %26
br label %15
39: ; preds = %15
br label %40
40: ; preds = %39, %11
%41 = load i32, i32* %6
ret i32 %41
}

LLVM IR (-O2):
@.str = [8 x i8] c"<stdin>\00"
@stdin = global i32* null
@.str.1 = [3 x i8] c"rb\00"
@stderr = global i32 0
@.str.2 = [34 x i8] c"disptrace: unable to open %s: %m\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 1
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = add nsw i32 %0, -1
br label %9
6: ; preds = %2
%7 = load i32*, i32** @stdin
%8 = tail call i32 @display_trace(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32* %7)
br label %28
9: ; preds = %4, %24
%10 = phi i32 [ %26, %24 ], [ %5, %4 ]
%11 = phi i8** [ %13, %24 ], [ %1, %4 ]
%12 = phi i32 [ %25, %24 ], [ 0, %4 ]
%13 = getelementptr inbounds i8*, i8** %11, i64 1
%14 = load i8*, i8** %13
%15 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %20, label %17
17: ; preds = %9
%18 = tail call i32 @display_trace(i8* %14, i32* %15)
%19 = tail call i32 @fclose(i32* %15)
br label %24
20: ; preds = %9
%21 = load i32, i32* @stderr
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%23 = add nsw i32 %12, 1
br label %24
24: ; preds = %20, %17
%25 = phi i32 [ %12, %17 ], [ %23, %20 ]
%26 = add nsw i32 %10, -1
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %9
28: ; preds = %24, %6
%29 = phi i32 [ 0, %6 ], [ %25, %24 ]
ret i32 %29
}