#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 */
scalar_t__ EOF;
int /*<<< orphan*/ Mac(unsigned char *, int, unsigned char *);
int /*<<< orphan*/ Oracle_Connect();
int /*<<< orphan*/ Oracle_Disconnect();
int Vrfy(unsigned char *, int, unsigned char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, unsigned char *);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  unsigned char message[512];
  unsigned char tag[16];
  int i, mlength, ret;
  FILE *fpIn;
  if (argc != 2) {
    printf("Usage: sample <filename>\n");
    return -1;
  }
  fpIn = fopen(argv[1], "r");
  for (i = 0; i < 512; i++) {
    if (fscanf(fpIn, "%c", &message[i]) == EOF)
      break;
  }
  fclose(fpIn);
  mlength = i;
  Oracle_Connect();
  Mac(message, mlength, tag);
  ret = Vrfy(message, mlength, tag);
  if (ret == 1) {
    printf("Message verified successfully!\n");
  } else {
    printf("Message verficiation failed.\n");
  }
  Oracle_Disconnect();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11bb <main+0x3b>
lea    0xe56(%rip),%rdi
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12ca <main+0x14a>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe50(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x238(%rbp)
movl   $0x0,-0x224(%rbp)
cmpl   $0x200,-0x224(%rbp)
jge    1242 <main+0xc2>
mov    -0x238(%rbp),%rdi
movslq -0x224(%rbp),%rax
lea    -0x210(%rbp),%rdx
add    %rax,%rdx
lea    0xe0d(%rip),%rsi
call   1070 <fscanf@plt>
mov    0x2dcd(%rip),%rcx
cmp    (%rcx),%rax
jne    1229 <main+0xa9>
jmp    1242 <main+0xc2>
jmp    122e <main+0xae>
mov    -0x224(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x224(%rbp)
jmp    11e0 <main+0x60>
mov    -0x238(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x224(%rbp),%eax
mov    %eax,-0x228(%rbp)
mov    $0x0,%al
call   1050 <Oracle_Connect@plt>
lea    -0x210(%rbp),%rdi
mov    -0x228(%rbp),%esi
lea    -0x220(%rbp),%rdx
call   1090 <Mac@plt>
lea    -0x210(%rbp),%rdi
mov    -0x228(%rbp),%esi
lea    -0x220(%rbp),%rdx
call   1080 <Vrfy@plt>
mov    %eax,-0x22c(%rbp)
cmpl   $0x1,-0x22c(%rbp)
jne    12b7 <main+0x137>
lea    0xd72(%rip),%rdi
call   1060 <printf@plt>
jmp    12c3 <main+0x143>
lea    0xd81(%rip),%rdi
call   1060 <printf@plt>
mov    $0x0,%al
call   1030 <Oracle_Disconnect@plt>
mov    -0x4(%rbp),%eax
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x218,%rsp
cmp    $0x2,%edi
jne    1240 <main+0xc0>
mov    0x8(%rsi),%rdi
lea    0xe5f(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbp
xor    %ebx,%ebx
lea    0xe50(%rip),%r14
mov    0x2e2f(%rip),%r15
nopl   0x0(%rax)
lea    (%rsp,%rbx,1),%rdx
add    $0x10,%rdx
mov    %rbp,%rdi
mov    %r14,%rsi
call   1070 <fscanf@plt>
cmp    (%r15),%rax
je     11ea <main+0x6a>
add    $0x1,%rbx
cmp    $0x200,%rbx
jne    11c0 <main+0x40>
mov    $0x200,%ebx
mov    %rbp,%rdi
call   1050 <fclose@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <Oracle_Connect@plt>
lea    0x10(%rsp),%r14
mov    %rsp,%r15
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r15,%rdx
call   1090 <Mac@plt>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %r15,%rdx
call   1080 <Vrfy@plt>
cmp    $0x1,%eax
lea    0xdfb(%rip),%rax
lea    0xdd7(%rip),%rdi
cmove  %rax,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1030 <Oracle_Disconnect@plt>
jmp    1251 <main+0xd1>
lea    0xdfa(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x218,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Usage: sample <filename>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%c\00"
@EOF = global i64 0
@.str.3 = [32 x i8] c"Message verified successfully!\0A\00"
@.str.4 = [30 x i8] c"Message verficiation failed.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [512 x i8]
%7 = alloca [16 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %58
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %11
store i32 0, i32* %8
br label %21
21: ; preds = %34, %16
%22 = load i32, i32* %8
%23 = icmp slt i32 %22, 512
br i1 %23, label %24, label %37
24: ; preds = %21
%25 = load i32*, i32** %11
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 %27
%29 = call i64 @fscanf(i32* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = load i64, i64* @EOF
%31 = icmp eq i64 %29, %30
br i1 %31, label %32, label %33
32: ; preds = %24
br label %37
33: ; preds = %24
br label %34
34: ; preds = %33
%35 = load i32, i32* %8
%36 = add nsw i32 %35, 1
store i32 %36, i32* %8
br label %21
37: ; preds = %32, %21
%38 = load i32*, i32** %11
%39 = call i32 @fclose(i32* %38)
%40 = load i32, i32* %8
store i32 %40, i32* %9
%41 = call i32 (...) @Oracle_Connect()
%42 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%43 = load i32, i32* %9
%44 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%45 = call i32 @Mac(i8* %42, i32 %43, i8* %44)
%46 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%47 = load i32, i32* %9
%48 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%49 = call i32 @Vrfy(i8* %46, i32 %47, i8* %48)
store i32 %49, i32* %10
%50 = load i32, i32* %10
%51 = icmp eq i32 %50, 1
br i1 %51, label %52, label %54
52: ; preds = %37
%53 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0))
br label %56
54: ; preds = %37
%55 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
br label %56
56: ; preds = %54, %52
%57 = call i32 (...) @Oracle_Disconnect()
br label %58
58: ; preds = %56, %14
%59 = load i32, i32* %3
ret i32 %59
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%c\00"
@EOF = global i64 0
@str = [29 x i8] c"Message verficiation failed.\00"
@str.5 = [31 x i8] c"Message verified successfully!\00"
@str.6 = [25 x i8] c"Usage: sample <filename>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [512 x i8]
%4 = alloca [16 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%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.6, i64 0, i64 0))
br label %35
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, %20
%15 = phi i64 [ 0, %10 ], [ %21, %20 ]
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %15
%17 = call i64 @fscanf(i32* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = load i64, i64* @EOF
%19 = icmp eq i64 %17, %18
br i1 %19, label %23, label %20
20: ; preds = %14
%21 = add nuw nsw i64 %15, 1
%22 = icmp eq i64 %21, 512
br i1 %22, label %25, label %14
23: ; preds = %14
%24 = trunc i64 %15 to i32
br label %25
25: ; preds = %20, %23
%26 = phi i32 [ %24, %23 ], [ 512, %20 ]
%27 = call i32 @fclose(i32* %13)
%28 = call i32 (...) @Oracle_Connect()
%29 = call i32 @Mac(i8* %5, i32 %26, i8* %6)
%30 = call i32 @Vrfy(i8* %5, i32 %26, i8* %6)
%31 = icmp eq i32 %30, 1
%32 = select i1 %31, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @str.5, i64 0, i64 0), i8* getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0)
%33 = call i32 @puts(i8* dereferenceable(1) %32)
%34 = call i32 (...) @Oracle_Disconnect()
br label %35
35: ; preds = %25, %8
%36 = phi i32 [ -1, %8 ], [ 0, %25 ]
ret i32 %36
}