#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*/ hostname;
typedef int /*<<< orphan*/ MD5_CTX;

/* Variables and functions */
int MD5_DIGEST_LENGTH;
int /*<<< orphan*/ MD5_Final(unsigned char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ MD5_Init(int /*<<< orphan*/ *);
int /*<<< orphan*/ MD5_Update(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
scalar_t__ gethostname(char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, unsigned int);
int /*<<< orphan*/ strlen(char *);
int main(int argc, char **argv) {
  MD5_CTX ctx;
  unsigned char md[MD5_DIGEST_LENGTH];
  char buf[17];
  char hostname[32];
  int i;
  if (gethostname(hostname, sizeof(hostname))) {
    perror("gethostname");
    return 1;
  }
  printf("Hostname:%s\n", hostname);
  MD5_Init(&ctx);
  MD5_Update(&ctx, hostname, strlen(hostname));
  MD5_Final(md, &ctx);
  for (i = 0; i < 8; i++) {
    sprintf(&buf[i * 2], "%02X", (unsigned int)md[i]);
  }
  printf("%s\n", buf);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e40(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x70(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
lea    -0x60(%rbp),%rdi
mov    $0x20,%esi
call   1080 <gethostname@plt>
cmp    $0x0,%rax
je     11fc <main+0x7c>
lea    0xe1c(%rip),%rdi
call   1060 <perror@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x68(%rbp)
jmp    12a7 <main+0x127>
lea    -0x60(%rbp),%rsi
lea    0xe05(%rip),%rdi
call   1050 <printf@plt>
lea    -0x14(%rbp),%rdi
call   1070 <MD5_Init@plt>
lea    -0x60(%rbp),%rax
mov    %rax,-0x78(%rbp)
lea    -0x60(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x78(%rbp),%rsi
mov    %eax,%edx
lea    -0x14(%rbp),%rdi
call   10a0 <MD5_Update@plt>
mov    -0x70(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1030 <MD5_Final@plt>
movl   $0x0,-0x64(%rbp)
cmpl   $0x8,-0x64(%rbp)
jge    1289 <main+0x109>
mov    -0x70(%rbp),%rax
mov    -0x64(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
lea    -0x40(%rbp),%rdi
add    %rcx,%rdi
movslq -0x64(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xda3(%rip),%rsi
call   1090 <sprintf@plt>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1249 <main+0xc9>
lea    -0x40(%rbp),%rsi
lea    0xd81(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x68(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x50,%rsp
mov    %rsp,%r12
mov    0x2e47(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    -0x70(%rbp),%rdi
mov    $0x20,%esi
call   1080 <gethostname@plt>
test   %rax,%rax
jne    12ac <main+0x12c>
lea    0xe42(%rip),%rdi
lea    -0x70(%rbp),%r14
mov    %r14,%rsi
call   1050 <printf@plt>
lea    -0x44(%rbp),%r15
mov    %r15,%rdi
call   1070 <MD5_Init@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   10a0 <MD5_Update@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <MD5_Final@plt>
movzbl (%rbx),%edx
lea    0xe0d(%rip),%r15
lea    -0x40(%rbp),%r14
mov    %r14,%rdi
mov    %r15,%rsi
call   1090 <sprintf@plt>
lea    -0x3e(%rbp),%rdi
movzbl 0x1(%rbx),%edx
mov    %r15,%rsi
call   1090 <sprintf@plt>
lea    -0x3c(%rbp),%rdi
movzbl 0x2(%rbx),%edx
mov    %r15,%rsi
call   1090 <sprintf@plt>
lea    -0x3a(%rbp),%rdi
movzbl 0x3(%rbx),%edx
mov    %r15,%rsi
call   1090 <sprintf@plt>
lea    -0x38(%rbp),%rdi
movzbl 0x4(%rbx),%edx
mov    %r15,%rsi
call   1090 <sprintf@plt>
lea    -0x36(%rbp),%rdi
movzbl 0x5(%rbx),%edx
mov    %r15,%rsi
call   1090 <sprintf@plt>
lea    -0x34(%rbp),%rdi
movzbl 0x6(%rbx),%edx
mov    %r15,%rsi
call   1090 <sprintf@plt>
lea    -0x32(%rbp),%rdi
movzbl 0x7(%rbx),%edx
mov    %r15,%rsi
call   1090 <sprintf@plt>
lea    0xd83(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
mov    %r12,%rsp
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd4d(%rip),%rdi
call   1060 <perror@plt>
mov    $0x1,%eax
jmp    129c <main+0x11c>

LLVM IR (-O0):
@MD5_DIGEST_LENGTH = global i32 0
@.str = [12 x i8] c"gethostname\00"
@.str.1 = [13 x i8] c"Hostname:%s\0A\00"
@.str.2 = [5 x i8] c"%02X\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca [17 x i8]
%10 = alloca [32 x i8]
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* @MD5_DIGEST_LENGTH
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %7
%16 = alloca i8, i64 %14
store i64 %14, i64* %8
%17 = getelementptr inbounds [32 x i8], [32 x i8]* %10, i64 0, i64 0
%18 = call i64 @gethostname(i8* %17, i32 32)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %2
%21 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
store i32 1, i32* %12
br label %51
22: ; preds = %2
%23 = getelementptr inbounds [32 x i8], [32 x i8]* %10, i64 0, i64 0
%24 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = call i32 @MD5_Init(i32* %6)
%26 = getelementptr inbounds [32 x i8], [32 x i8]* %10, i64 0, i64 0
%27 = getelementptr inbounds [32 x i8], [32 x i8]* %10, i64 0, i64 0
%28 = call i32 @strlen(i8* %27)
%29 = call i32 @MD5_Update(i32* %6, i8* %26, i32 %28)
%30 = call i32 @MD5_Final(i8* %16, i32* %6)
store i32 0, i32* %11
br label %31
31: ; preds = %45, %22
%32 = load i32, i32* %11
%33 = icmp slt i32 %32, 8
br i1 %33, label %34, label %48
34: ; preds = %31
%35 = load i32, i32* %11
%36 = mul nsw i32 %35, 2
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [17 x i8], [17 x i8]* %9, i64 0, i64 %37
%39 = load i32, i32* %11
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %16, i64 %40
%42 = load i8, i8* %41
%43 = zext i8 %42 to i32
%44 = call i32 @sprintf(i8* %38, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %34
%46 = load i32, i32* %11
%47 = add nsw i32 %46, 1
store i32 %47, i32* %11
br label %31
48: ; preds = %31
%49 = getelementptr inbounds [17 x i8], [17 x i8]* %9, i64 0, i64 0
%50 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %49)
store i32 0, i32* %3
store i32 1, i32* %12
br label %51
51: ; preds = %48, %20
%52 = load i8*, i8** %7
%53 = load i32, i32* %3
ret i32 %53
}

LLVM IR (-O2):
@MD5_DIGEST_LENGTH = global i32 0
@.str = [12 x i8] c"gethostname\00"
@.str.1 = [13 x i8] c"Hostname:%s\0A\00"
@.str.2 = [5 x i8] c"%02X\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [17 x i8]
%5 = alloca [32 x i8]
%6 = bitcast i32* %3 to i8*
%7 = load i32, i32* @MD5_DIGEST_LENGTH
%8 = zext i32 %7 to i64
%9 = tail call i8* @llvm.stacksave()
%10 = alloca i8, i64 %8
%11 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%13 = call i64 @gethostname(i8* %12, i32 32)
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %2
%16 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
br label %62
17: ; preds = %2
%18 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%19 = call i32 @MD5_Init(i32* %3)
%20 = call i32 @strlen(i8* %12)
%21 = call i32 @MD5_Update(i32* %3, i8* %12, i32 %20)
%22 = call i32 @MD5_Final(i8* %10, i32* %3)
%23 = load i8, i8* %10
%24 = zext i8 %23 to i32
%25 = call i32 @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 2
%27 = getelementptr inbounds i8, i8* %10, i64 1
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = call i32 @sprintf(i8* %26, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %29)
%31 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 4
%32 = getelementptr inbounds i8, i8* %10, i64 2
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = call i32 @sprintf(i8* %31, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%36 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 6
%37 = getelementptr inbounds i8, i8* %10, i64 3
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = call i32 @sprintf(i8* %36, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %39)
%41 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 8
%42 = getelementptr inbounds i8, i8* %10, i64 4
%43 = load i8, i8* %42
%44 = zext i8 %43 to i32
%45 = call i32 @sprintf(i8* %41, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %44)
%46 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 10
%47 = getelementptr inbounds i8, i8* %10, i64 5
%48 = load i8, i8* %47
%49 = zext i8 %48 to i32
%50 = call i32 @sprintf(i8* %46, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %49)
%51 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 12
%52 = getelementptr inbounds i8, i8* %10, i64 6
%53 = load i8, i8* %52
%54 = zext i8 %53 to i32
%55 = call i32 @sprintf(i8* %51, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %54)
%56 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 14
%57 = getelementptr inbounds i8, i8* %10, i64 7
%58 = load i8, i8* %57
%59 = zext i8 %58 to i32
%60 = call i32 @sprintf(i8* %56, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %59)
%61 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %11)
br label %62
62: ; preds = %17, %15
%63 = phi i32 [ 1, %15 ], [ 0, %17 ]
ret i32 %63
}