#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 */
size_t defl(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ unlink(char *);
size_t get_zsize(char *infile) {
  FILE *in;
  FILE *z;
  size_t zsize;
  if ((in = fopen(infile, "rb")) == NULL) {
    perror("Could not open infile");
    exit(1);
  }
  if ((z = fopen("/tmp/analyze.z", "wb")) == NULL) {
    perror("Could not open zfile");
    exit(1);
  }
  zsize = defl(in, z, 9);
  fclose(in);
  fclose(z);
  unlink("/tmp/analyze.z");
  return zsize;
}


x86 assembly (clang, -O0):
<get_zsize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe89(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11a0 <get_zsize+0x40>
lea    0xe72(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xe72(%rip),%rdi
lea    0xe7a(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11d7 <get_zsize+0x77>
lea    0xe63(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x9,%edx
call   1070 <defl@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
lea    0xe13(%rip),%rdi
call   1030 <unlink@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_zsize>:
push   %r15
push   %r14
push   %rbx
lea    0xe94(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11cc <get_zsize+0x6c>
mov    %rax,%r14
lea    0xe99(%rip),%rdi
lea    0xea1(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     11d5 <get_zsize+0x75>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
mov    $0x9,%edx
call   1070 <defl@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
lea    0xe5b(%rip),%rdi
call   1030 <unlink@plt>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe30(%rip),%rdi
jmp    11dc <get_zsize+0x7c>
lea    0xe4f(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [22 x i8] c"Could not open infile\00"
@.str.2 = [15 x i8] c"/tmp/analyze.z\00"
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [21 x i8] c"Could not open zfile\00"
define i64 @get_zsize(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i64
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %7, i32** %3
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %1
%13 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %13, i32** %4
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %12
%19 = load i32*, i32** %3
%20 = load i32*, i32** %4
%21 = call i64 @defl(i32* %19, i32* %20, i32 9)
store i64 %21, i64* %5
%22 = load i32*, i32** %3
%23 = call i32 @fclose(i32* %22)
%24 = load i32*, i32** %4
%25 = call i32 @fclose(i32* %24)
%26 = call i32 @unlink(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%27 = load i64, i64* %5
ret i64 %27
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [22 x i8] c"Could not open infile\00"
@.str.2 = [15 x i8] c"/tmp/analyze.z\00"
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [21 x i8] c"Could not open zfile\00"
define i64 @get_zsize(i8* nocapture %0) {
%2 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %1
%8 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %7
%14 = tail call i64 @defl(i32* %2, i32* %8, i32 9)
%15 = tail call i32 @fclose(i32* %2)
%16 = tail call i32 @fclose(i32* %8)
%17 = tail call i32 @unlink(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
ret i64 %14
}