#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*/ assert(int);
int fopen_s(int /*<<< orphan*/ **, char *, char *);
long milk_file_get_size_f(int /*<<< orphan*/ *);
long milk_file_get_size_s(char *);
int /*<<< orphan*/ printf(char *);
void test_milk(void) {
  long res1, res2;
  FILE *file;
  printf("Testing milk get file size.. ");
  res1 = milk_file_get_size_s("src/test.c");
  assert(res1 > 0);
  int err = fopen_s(&file, "src/test.c", "rb");
  assert(!err);
  res2 = milk_file_get_size_f(file);
  assert(res2 > 0);
  assert(res1 == res2);
  printf("Success\n");
}


x86 assembly (clang, -O0):
<test_milk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xea1(%rip),%rdi
call   1050 <printf@plt>
lea    0xeb3(%rip),%rdi
call   1040 <milk_file_get_size_s@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    -0x18(%rbp),%rdi
lea    0xe8d(%rip),%rsi
lea    0xe91(%rip),%rdx
call   1030 <fopen_s@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x18(%rbp),%rdi
call   1070 <milk_file_get_size_f@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x8(%rbp),%rax
cmp    -0x10(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xe3e(%rip),%rdi
call   1050 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_milk>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe90(%rip),%rdi
call   1060 <printf@plt>
lea    0xea2(%rip),%r14
mov    %r14,%rdi
call   1050 <milk_file_get_size_s@plt>
mov    %rax,%r15
xor    %edi,%edi
test   %rax,%rax
setg   %dil
call   1070 <assert@plt>
lea    0xe8d(%rip),%rdx
lea    0x8(%rsp),%rdi
mov    %r14,%rsi
call   1030 <fopen_s@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1070 <assert@plt>
mov    0x8(%rsp),%rdi
call   1080 <milk_file_get_size_f@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setg   %dil
call   1070 <assert@plt>
xor    %edi,%edi
cmp    %rbx,%r15
sete   %dil
call   1070 <assert@plt>
lea    0xe46(%rip),%rdi
call   1040 <puts@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Testing milk get file size.. \00"
@.str.1 = [11 x i8] c"src/test.c\00"
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [9 x i8] c"Success\0A\00"
define void @test_milk() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i32*
%4 = alloca i32
%5 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%6 = call i64 @milk_file_get_size_s(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i64 %6, i64* %1
%7 = load i64, i64* %1
%8 = icmp sgt i64 %7, 0
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = call i32 @fopen_s(i32** %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 0
%14 = xor i1 %13, true
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = load i32*, i32** %3
%18 = call i64 @milk_file_get_size_f(i32* %17)
store i64 %18, i64* %2
%19 = load i64, i64* %2
%20 = icmp sgt i64 %19, 0
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = load i64, i64* %1
%24 = load i64, i64* %2
%25 = icmp eq i64 %23, %24
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c"Testing milk get file size.. \00"
@.str.1 = [11 x i8] c"src/test.c\00"
@.str.2 = [3 x i8] c"rb\00"
@str = [8 x i8] c"Success\00"
define void @test_milk() {
%1 = alloca i32*
%2 = bitcast i32** %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%4 = tail call i64 @milk_file_get_size_s(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp sgt i64 %4, 0
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = call i32 @fopen_s(i32** %1, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load i32*, i32** %1
%13 = call i64 @milk_file_get_size_f(i32* %12)
%14 = icmp sgt i64 %13, 0
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = icmp eq i64 %4, %13
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
ret void
}