#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*/ Oracle_Connect();
int /*<<< orphan*/ Oracle_Disconnect();
int Oracle_Send(unsigned char *, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  unsigned char ctext[48];
  int i, tmp, ret;
  FILE *fpIn;
  if (argc != 2) {
    printf("Usage: sample <filename>\n");
    return -1;
  }
  fpIn = fopen(argv[1], "r");
  for (i = 0; i < 48; i++) {
    fscanf(fpIn, "%02x", &tmp);
    ctext[i] = tmp;
  }
  fclose(fpIn);
  Oracle_Connect();
  ret = Oracle_Send(ctext, 3);
  printf("Oracle returned: %d\n", ret);
  Oracle_Disconnect();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11aa <main+0x3a>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    123b <main+0xcb>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe61(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x58(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x30,-0x44(%rbp)
jge    1202 <main+0x92>
mov    -0x58(%rbp),%rdi
lea    0xe3e(%rip),%rsi
lea    -0x48(%rbp),%rdx
call   1070 <fscanf@plt>
mov    -0x48(%rbp),%eax
mov    %al,%cl
movslq -0x44(%rbp),%rax
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11c9 <main+0x59>
mov    -0x58(%rbp),%rdi
call   1040 <fclose@plt>
mov    $0x0,%al
call   1050 <Oracle_Connect@plt>
lea    -0x40(%rbp),%rdi
mov    $0x3,%esi
call   1080 <Oracle_Send@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%esi
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1030 <Oracle_Disconnect@plt>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x48,%rsp
cmp    $0x2,%edi
jne    121a <main+0x9a>
mov    0x8(%rsi),%rdi
lea    0xe61(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%r12
xor    %ebx,%ebx
lea    0xe52(%rip),%r14
lea    0xc(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1080 <fscanf@plt>
movzbl 0xc(%rsp),%eax
mov    %al,0x10(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x30,%rbx
jne    11c0 <main+0x40>
mov    %r12,%rdi
call   1050 <fclose@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <Oracle_Connect@plt>
lea    0x10(%rsp),%rdi
mov    $0x3,%esi
call   1090 <Oracle_Send@plt>
lea    0xdff(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %eax,%eax
call   1030 <Oracle_Disconnect@plt>
jmp    122b <main+0xab>
lea    0xdfb(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Usage: sample <filename>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [5 x i8] c"%02x\00"
@.str.3 = [21 x i8] c"Oracle returned: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [48 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %43
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32* @fopen(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %19, i32** %10
store i32 0, i32* %7
br label %20
20: ; preds = %31, %15
%21 = load i32, i32* %7
%22 = icmp slt i32 %21, 48
br i1 %22, label %23, label %34
23: ; preds = %20
%24 = load i32*, i32** %10
%25 = call i32 @fscanf(i32* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %8)
%26 = load i32, i32* %8
%27 = trunc i32 %26 to i8
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [48 x i8], [48 x i8]* %6, i64 0, i64 %29
store i8 %27, i8* %30
br label %31
31: ; preds = %23
%32 = load i32, i32* %7
%33 = add nsw i32 %32, 1
store i32 %33, i32* %7
br label %20
34: ; preds = %20
%35 = load i32*, i32** %10
%36 = call i32 @fclose(i32* %35)
%37 = call i32 (...) @Oracle_Connect()
%38 = getelementptr inbounds [48 x i8], [48 x i8]* %6, i64 0, i64 0
%39 = call i32 @Oracle_Send(i8* %38, i32 3)
store i32 %39, i32* %9
%40 = load i32, i32* %9
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %40)
%42 = call i32 (...) @Oracle_Disconnect()
br label %43
43: ; preds = %34, %13
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [5 x i8] c"%02x\00"
@.str.3 = [21 x i8] c"Oracle returned: %d\0A\00"
@str = [25 x i8] c"Usage: sample <filename>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [48 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [48 x i8], [48 x i8]* %3, i64 0, i64 0
%6 = bitcast i32* %4 to i8*
%7 = icmp eq i32 %0, 2
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %28
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %10, %14
%15 = phi i64 [ 0, %10 ], [ %20, %14 ]
%16 = call i32 @fscanf(i32* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%17 = load i32, i32* %4
%18 = trunc i32 %17 to i8
%19 = getelementptr inbounds [48 x i8], [48 x i8]* %3, i64 0, i64 %15
store i8 %18, i8* %19
%20 = add nuw nsw i64 %15, 1
%21 = icmp eq i64 %20, 48
br i1 %21, label %22, label %14
22: ; preds = %14
%23 = call i32 @fclose(i32* %13)
%24 = call i32 (...) @Oracle_Connect()
%25 = call i32 @Oracle_Send(i8* %5, i32 3)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = call i32 (...) @Oracle_Disconnect()
br label %28
28: ; preds = %22, %8
%29 = phi i32 [ -1, %8 ], [ 0, %22 ]
ret i32 %29
}