#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 BUFSIZ;
int /*<<< orphan*/ die(char *, char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
size_t fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, size_t, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
char *tracecmd_get_tracing_file(char *);
int /*<<< orphan*/ tracecmd_put_tracing_file(char *);
void show_options(void) {
  char buf[BUFSIZ];
  char *path;
  FILE *fp;
  size_t n;
  path = tracecmd_get_tracing_file("trace_options");
  fp = fopen(path, "r");
  if (!fp)
    die("reading %s", path);
  tracecmd_put_tracing_file(path);
  do {
    n = fread(buf, 1, BUFSIZ, fp);
    if (n > 0)
      fwrite(buf, 1, n, stdout);
  } while (n > 0);
  fclose(fp);
}


x86 assembly (clang, -O0):
<show_options>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x2e61(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x8(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x10(%rbp)
lea    0xe55(%rip),%rdi
call   1060 <tracecmd_get_tracing_file@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe4f(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11e3 <show_options+0x73>
mov    -0x18(%rbp),%rsi
lea    0xe32(%rip),%rdi
call   1080 <die@plt>
mov    -0x18(%rbp),%rdi
call   1030 <tracecmd_put_tracing_file@plt>
mov    -0x30(%rbp),%rdi
mov    0x2de9(%rip),%rax
mov    (%rax),%edx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fread@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jbe    1231 <show_options+0xc1>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    0x2db3(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1090 <fwrite@plt>
jmp    1236 <show_options+0xc6>
cmpq   $0x0,-0x28(%rbp)
ja     11ec <show_options+0x7c>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x8(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_options>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    0x2e5e(%rip),%r12
mov    (%r12),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe62(%rip),%rdi
call   1060 <tracecmd_get_tracing_file@plt>
mov    %rax,%r15
lea    0xe61(%rip),%rsi
mov    %rax,%rdi
call   1070 <fopen@plt>
mov    %rax,%r14
test   %rax,%rax
jne    11cc <show_options+0x5c>
lea    0xe4c(%rip),%rdi
mov    %r15,%rsi
call   1080 <die@plt>
mov    %r15,%rdi
call   1030 <tracecmd_put_tracing_file@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r14,%rcx
call   1040 <fread@plt>
test   %rax,%rax
je     122c <show_options+0xbc>
mov    0x2de4(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r15),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %rax,%rdx
call   1090 <fwrite@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %r14,%rcx
call   1040 <fread@plt>
test   %rax,%rax
jne    1200 <show_options+0x90>
mov    %r14,%rdi
call   1050 <fclose@plt>
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@BUFSIZ = global i32 0
@.str = [14 x i8] c"trace_options\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"reading %s\00"
@stdout = global i32 0
define void @show_options() {
%1 = alloca i8*
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i64
%6 = load i32, i32* @BUFSIZ
%7 = zext i32 %6 to i64
%8 = call i8* @llvm.stacksave()
store i8* %8, i8** %1
%9 = alloca i8, i64 %7
store i64 %7, i64* %2
%10 = call i8* @tracecmd_get_tracing_file(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i8* %10, i8** %3
%11 = load i8*, i8** %3
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %4
%13 = load i32*, i32** %4
%14 = icmp ne i32* %13, null
br i1 %14, label %18, label %15
15: ; preds = %0
%16 = load i8*, i8** %3
%17 = call i32 @die(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %15, %0
%19 = load i8*, i8** %3
%20 = call i32 @tracecmd_put_tracing_file(i8* %19)
br label %21
21: ; preds = %32, %18
%22 = load i32, i32* @BUFSIZ
%23 = load i32*, i32** %4
%24 = call i64 @fread(i8* %9, i32 1, i32 %22, i32* %23)
store i64 %24, i64* %5
%25 = load i64, i64* %5
%26 = icmp ugt i64 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %21
%28 = load i64, i64* %5
%29 = load i32, i32* @stdout
%30 = call i32 @fwrite(i8* %9, i32 1, i64 %28, i32 %29)
br label %31
31: ; preds = %27, %21
br label %32
32: ; preds = %31
%33 = load i64, i64* %5
%34 = icmp ugt i64 %33, 0
br i1 %34, label %21, label %35
35: ; preds = %32
%36 = load i32*, i32** %4
%37 = call i32 @fclose(i32* %36)
%38 = load i8*, i8** %1
ret void
}

LLVM IR (-O2):
@BUFSIZ = global i32 0
@.str = [14 x i8] c"trace_options\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [11 x i8] c"reading %s\00"
@stdout = global i32 0
define void @show_options() {
%1 = load i32, i32* @BUFSIZ
%2 = zext i32 %1 to i64
%3 = alloca i8, i64 %2
%4 = tail call i8* @tracecmd_get_tracing_file(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = tail call i32 @die(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %4)
br label %9
9: ; preds = %7, %0
%10 = tail call i32 @tracecmd_put_tracing_file(i8* %4)
%11 = load i32, i32* @BUFSIZ
%12 = call i64 @fread(i8* %3, i32 1, i32 %11, i32* %5)
%13 = icmp eq i64 %12, 0
br i1 %13, label %21, label %14
14: ; preds = %9, %14
%15 = phi i64 [ %19, %14 ], [ %12, %9 ]
%16 = load i32, i32* @stdout
%17 = call i32 @fwrite(i8* %3, i32 1, i64 %15, i32 %16)
%18 = load i32, i32* @BUFSIZ
%19 = call i64 @fread(i8* %3, i32 1, i32 %18, i32* %5)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %14
21: ; preds = %14, %9
%22 = call i32 @fclose(i32* %5)
ret void
}