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

/* Variables and functions */
int /*<<< orphan*/ md5_file(char *, char *);
int /*<<< orphan*/ md5_string(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read_input(char *, int);
scalar_t__ strcmp(char *, char *);
int main(int argc, char **argv) {
  char md5[33];
  char buff[512];
  while (1) {
    printf("1. string  2. file: ");
    read_input(buff, sizeof(buff));
    if (strcmp(buff, "1") == 0) {
      printf("input string: ");
      read_input(buff, sizeof(buff));
      md5_string(buff, md5);
      printf("%s\n", md5);
    } else if (strcmp(buff, "2") == 0) {
      printf("input file name: ");
      read_input(buff, sizeof(buff));
      md5_file(buff, md5);
      printf("%s\n", md5);
    }
  }
  return 0;
}


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)
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x240(%rbp),%rdi
mov    $0x200,%esi
call   1070 <read_input@plt>
lea    -0x240(%rbp),%rdi
lea    0xe7f(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11eb <main+0x9b>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x240(%rbp),%rdi
mov    $0x200,%esi
call   1070 <read_input@plt>
lea    -0x240(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1060 <md5_string@plt>
lea    -0x40(%rbp),%rsi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    124e <main+0xfe>
lea    -0x240(%rbp),%rdi
lea    0xe31(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    1249 <main+0xf9>
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x240(%rbp),%rdi
mov    $0x200,%esi
call   1070 <read_input@plt>
lea    -0x240(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1030 <md5_file@plt>
lea    -0x40(%rbp),%rsi
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    124e <main+0xfe>
jmp    1169 <main+0x19>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x238,%rsp
lea    0xe88(%rip),%r14
lea    0x30(%rsp),%rbx
lea    0xe91(%rip),%r15
lea    0xe8c(%rip),%r12
mov    %rsp,%r13
lea    0xe91(%rip),%rbp
jmp    11ca <main+0x6a>
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x200,%esi
call   1080 <read_input@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1070 <md5_string@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x200,%esi
call   1080 <read_input@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11a0 <main+0x40>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
jne    11ca <main+0x6a>
lea    0xe20(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    $0x200,%esi
call   1080 <read_input@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1030 <md5_file@plt>
jmp    11c2 <main+0x62>

LLVM IR (-O0):
@.str = [21 x i8] c"1. string 2. file: \00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [15 x i8] c"input string: \00"
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [2 x i8] c"2\00"
@.str.5 = [18 x i8] c"input file name: \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [33 x i8]
%7 = alloca [512 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %8
8: ; preds = %2, %38
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%11 = call i32 @read_input(i8* %10, i32 512)
%12 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%13 = call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %8
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%18 = call i32 @read_input(i8* %17, i32 512)
%19 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%20 = getelementptr inbounds [33 x i8], [33 x i8]* %6, i64 0, i64 0
%21 = call i32 @md5_string(i8* %19, i8* %20)
%22 = getelementptr inbounds [33 x i8], [33 x i8]* %6, i64 0, i64 0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %22)
br label %38
24: ; preds = %8
%25 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%26 = call i64 @strcmp(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %37
28: ; preds = %24
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%30 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%31 = call i32 @read_input(i8* %30, i32 512)
%32 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%33 = getelementptr inbounds [33 x i8], [33 x i8]* %6, i64 0, i64 0
%34 = call i32 @md5_file(i8* %32, i8* %33)
%35 = getelementptr inbounds [33 x i8], [33 x i8]* %6, i64 0, i64 0
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %35)
br label %37
37: ; preds = %28, %24
br label %38
38: ; preds = %37, %15
br label %8
}

LLVM IR (-O2):
@.str = [21 x i8] c"1. string 2. file: \00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [15 x i8] c"input string: \00"
@.str.4 = [2 x i8] c"2\00"
@.str.5 = [18 x i8] c"input file name: \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [33 x i8]
%4 = alloca [512 x i8]
%5 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
br label %7
7: ; preds = %25, %2
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @read_input(i8* %6, i32 512)
%10 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @read_input(i8* %6, i32 512)
%15 = call i32 @md5_string(i8* %6, i8* %5)
br label %23
16: ; preds = %7
%17 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %16
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%21 = call i32 @read_input(i8* %6, i32 512)
%22 = call i32 @md5_file(i8* %6, i8* %5)
br label %23
23: ; preds = %12, %19
%24 = call i32 @puts(i8* %5)
br label %25
25: ; preds = %23, %16
br label %7
}