#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*/ O_RDONLY;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fdopen(int, char *);
int fileno(int /*<<< orphan*/ *);
int fread(char *, int, int, int /*<<< orphan*/ *);
scalar_t__ memcmp(char *, char *, int);
int open(char *, int /*<<< orphan*/);
int strlen(char const *);
int main(int argc, char *argv[]) {
  assert(argc == 2);
  int fd = open(argv[1], O_RDONLY);
  assert(fd > 0);
  FILE *file = fdopen(fd, "r");
  assert(fd == fileno(file));
  char buf[100];
  int count = fread(buf, 1, sizeof buf, file);
  const char expected[] = "Testing Data!";
  assert(count == strlen(expected));
  assert(memcmp(buf, "Testing Data!", count) == 0);
  fclose(file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e2f(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x14(%rbp),%edi
lea    0xe22(%rip),%rsi
call   1090 <fdopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0xac(%rbp)
mov    -0x20(%rbp),%rdi
call   1080 <fileno@plt>
mov    %eax,%ecx
mov    -0xac(%rbp),%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    -0x90(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
mov    $0x64,%edx
call   1030 <fread@plt>
mov    %eax,-0x94(%rbp)
mov    0xdcb(%rip),%rax
mov    %rax,-0xa2(%rbp)
mov    0xdc6(%rip),%eax
mov    %eax,-0x9a(%rbp)
mov    0xdbd(%rip),%ax
mov    %ax,-0x96(%rbp)
mov    -0x94(%rbp),%eax
mov    %eax,-0xa8(%rbp)
lea    -0xa2(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0xa8(%rbp),%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    -0x90(%rbp),%rdi
mov    -0x94(%rbp),%edx
lea    0xd67(%rip),%rsi
call   1060 <memcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x78,%rsp
mov    %rsi,%rbx
xor    %eax,%eax
cmp    $0x2,%edi
sete   %al
mov    %eax,%edi
call   1070 <assert@plt>
mov    0x8(%rbx),%rdi
mov    0x2e41(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
mov    %eax,%ebp
xor    %edi,%edi
test   %eax,%eax
setg   %dil
call   1070 <assert@plt>
lea    0xe3c(%rip),%rsi
mov    %ebp,%edi
call   1090 <fdopen@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <fileno@plt>
xor    %edi,%edi
cmp    %eax,%ebp
sete   %dil
call   1070 <assert@plt>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x64,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    %eax,%ebp
movabs $0x21617461442067,%rax
mov    %rax,0x6(%rsp)
movabs $0x20676e6974736554,%rax
6e 67 20
mov    %rax,(%rsp)
lea    0xddf(%rip),%r15
mov    %rsp,%rdi
call   1050 <strlen@plt>
xor    %edi,%edi
cmp    %eax,%ebp
sete   %dil
call   1070 <assert@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1060 <memcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@O_RDONLY = global i32 0
@.str = [2 x i8] c"r\00"
@__const.main.expected = [14 x i8] c"Testing Data!\00"
@.str.1 = [14 x i8] c"Testing Data!\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca [100 x i8]
%9 = alloca i32
%10 = alloca [14 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 2
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = load i32, i32* @O_RDONLY
%19 = call i32 @open(i8* %17, i32 %18)
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = icmp sgt i32 %20, 0
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = load i32, i32* %6
%25 = call i32* @fdopen(i32 %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %25, i32** %7
%26 = load i32, i32* %6
%27 = load i32*, i32** %7
%28 = call i32 @fileno(i32* %27)
%29 = icmp eq i32 %26, %28
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%33 = load i32*, i32** %7
%34 = call i32 @fread(i8* %32, i32 1, i32 100, i32* %33)
store i32 %34, i32* %9
%35 = bitcast [14 x i8]* %10 to i8*
%36 = load i32, i32* %9
%37 = getelementptr inbounds [14 x i8], [14 x i8]* %10, i64 0, i64 0
%38 = call i32 @strlen(i8* %37)
%39 = icmp eq i32 %36, %38
%40 = zext i1 %39 to i32
%41 = call i32 @assert(i32 %40)
%42 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%43 = load i32, i32* %9
%44 = call i64 @memcmp(i8* %42, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %43)
%45 = icmp eq i64 %44, 0
%46 = zext i1 %45 to i32
%47 = call i32 @assert(i32 %46)
%48 = load i32*, i32** %7
%49 = call i32 @fclose(i32* %48)
ret i32 0
}

LLVM IR (-O2):
@O_RDONLY = global i32 0
@.str = [2 x i8] c"r\00"
@.str.1 = [14 x i8] c"Testing Data!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [100 x i8]
%4 = alloca [14 x i8]
%5 = icmp eq i32 %0, 2
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = load i32, i32* @O_RDONLY
%11 = tail call i32 @open(i8* %9, i32 %10)
%12 = icmp sgt i32 %11, 0
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
%15 = tail call i32* @fdopen(i32 %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = tail call i32 @fileno(i32* %15)
%17 = icmp eq i32 %11, %16
%18 = zext i1 %17 to i32
%19 = tail call i32 @assert(i32 %18)
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%21 = call i32 @fread(i8* %20, i32 1, i32 100, i32* %15)
%22 = getelementptr inbounds [14 x i8], [14 x i8]* %4, i64 0, i64 0
%23 = call i32 @strlen(i8* %22)
%24 = icmp eq i32 %21, %23
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = call i64 @memcmp(i8* %20, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%28 = icmp eq i64 %27, 0
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = call i32 @fclose(i32* %15)
ret i32 0
}