#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 */

/* Variables and functions */
int /*<<< orphan*/ free(unsigned char *);
unsigned char *get_filehash(char *);
unsigned char *get_padblock(unsigned char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  unsigned char *hash;
  unsigned char *pad_block;
  unsigned int i;
  if (argc < 2) {
    printf("File required!\n");
    return 1;
  }
  hash = get_filehash(argv[1]);
  if (!hash)
    return 1;
  pad_block = get_padblock(hash);
  for (i = 0; i < 2048 / 8; i++) {
    if ((i % 16) == 0)
      printf("\n");
    printf("%02X", pad_block[i]);
  }
  printf("\n\n");
  free(pad_block);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    117a <main+0x3a>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1225 <main+0xe5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <get_filehash@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11a2 <main+0x62>
movl   $0x1,-0x4(%rbp)
jmp    1225 <main+0xe5>
mov    -0x18(%rbp),%rdi
call   1060 <get_padblock@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x100,-0x24(%rbp)
jae    1207 <main+0xc7>
mov    -0x24(%rbp),%eax
and    $0xf,%eax
cmp    $0x0,%eax
jne    11e0 <main+0xa0>
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
movzbl (%rax,%rcx,1),%esi
lea    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11b6 <main+0x76>
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
cmp    $0x1,%edi
jg     1178 <main+0x18>
lea    0xe96(%rip),%rdi
call   1050 <puts@plt>
jmp    11cd <main+0x6d>
mov    0x8(%rsi),%rdi
call   1070 <get_filehash@plt>
test   %rax,%rax
je     11cd <main+0x6d>
mov    %rax,%rdi
call   1080 <get_padblock@plt>
mov    %rax,%r15
lea    0xe68(%rip),%r14
xor    %ebx,%ebx
jmp    11bc <main+0x5c>
nopl   0x0(%rax)
movzbl (%r15,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x1,%rbx
cmp    $0x100,%rbx
je     11d4 <main+0x74>
test   $0xf,%bl
jne    11a0 <main+0x40>
mov    $0xa,%edi
call   1040 <putchar@plt>
jmp    11a0 <main+0x40>
mov    $0x1,%eax
jmp    11ea <main+0x8a>
lea    0xe2a(%rip),%rdi
call   1050 <puts@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [16 x i8] c"File required!\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [5 x i8] c"%02X\00"
@.str.3 = [3 x i8] c"\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %48
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i8* @get_filehash(i8* %16)
store i8* %17, i8** %6
%18 = load i8*, i8** %6
%19 = icmp ne i8* %18, null
br i1 %19, label %21, label %20
20: ; preds = %13
store i32 1, i32* %3
br label %48
21: ; preds = %13
%22 = load i8*, i8** %6
%23 = call i8* @get_padblock(i8* %22)
store i8* %23, i8** %7
store i32 0, i32* %8
br label %24
24: ; preds = %41, %21
%25 = load i32, i32* %8
%26 = icmp ult i32 %25, 256
br i1 %26, label %27, label %44
27: ; preds = %24
%28 = load i32, i32* %8
%29 = urem i32 %28, 16
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %33
33: ; preds = %31, %27
%34 = load i8*, i8** %7
%35 = load i32, i32* %8
%36 = zext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %33
%42 = load i32, i32* %8
%43 = add i32 %42, 1
store i32 %43, i32* %8
br label %24
44: ; preds = %24
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%46 = load i8*, i8** %7
%47 = call i32 @free(i8* %46)
store i32 0, i32* %3
br label %48
48: ; preds = %44, %20, %11
%49 = load i32, i32* %3
ret i32 %49
}

LLVM IR (-O2):
@.str.2 = [5 x i8] c"%02X\00"
@str = [2 x i8] c"\0A\00"
@str.4 = [15 x i8] c"File required!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.4, i64 0, i64 0))
br label %29
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i8* @get_filehash(i8* %8)
%10 = icmp eq i8* %9, null
br i1 %10, label %29, label %11
11: ; preds = %6
%12 = tail call i8* @get_padblock(i8* %9)
br label %13
13: ; preds = %11, %19
%14 = phi i64 [ 0, %11 ], [ %24, %19 ]
%15 = and i64 %14, 15
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = tail call i32 @putchar(i32 10)
br label %19
19: ; preds = %17, %13
%20 = getelementptr inbounds i8, i8* %12, i64 %14
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = add nuw nsw i64 %14, 1
%25 = icmp eq i64 %24, 256
br i1 %25, label %26, label %13
26: ; preds = %19
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
%28 = tail call i32 @free(i8* %12)
br label %29
29: ; preds = %6, %26, %4
%30 = phi i32 [ 1, %4 ], [ 0, %26 ], [ 1, %6 ]
ret i32 %30
}