#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*/ TDES(unsigned char *, int, unsigned char *, unsigned char *,
                        int);
int /*<<< orphan*/ hex2bin(char *, unsigned char *);
scalar_t__ memcmp(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ memcpy(unsigned char *, char *, int);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int main(int argc, char *argv[]) {
  unsigned char urandom[200];
  unsigned char uencode[200];
  unsigned char ukey[17];
  unsigned char uclient[16];
  memset(urandom, 0, 200);
  memset(uencode, 0, 200);
  memset(ukey, 0, 17);
  if (argc != 4) {
    return 4;
  }
  char *client_hex = argv[1];
  memcpy(ukey, argv[2], 16);
  memcpy(urandom, argv[3], 16);
  TDES(ukey, 1, uencode, urandom, 200);
  hex2bin(client_hex, uclient);
  return (memcmp(uencode, uclient, 16) == 0 ? 0 : 5);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1f0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0xe0(%rbp),%rdi
xor    %esi,%esi
mov    $0xc8,%edx
call   1040 <memset@plt>
lea    -0x1b0(%rbp),%rdi
xor    %esi,%esi
mov    $0xc8,%edx
call   1040 <memset@plt>
lea    -0x1d0(%rbp),%rdi
xor    %esi,%esi
mov    $0x11,%edx
call   1040 <memset@plt>
cmpl   $0x4,-0x8(%rbp)
je     11b8 <main+0x68>
movl   $0x4,-0x4(%rbp)
jmp    125d <main+0x10d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x1e8(%rbp)
lea    -0x1d0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    $0x10,%edx
call   1060 <memcpy@plt>
lea    -0xe0(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
mov    $0x10,%edx
call   1060 <memcpy@plt>
lea    -0x1d0(%rbp),%rdi
lea    -0x1b0(%rbp),%rdx
lea    -0xe0(%rbp),%rcx
mov    $0x1,%esi
mov    $0xc8,%r8d
call   1070 <TDES@plt>
mov    -0x1e8(%rbp),%rdi
lea    -0x1e0(%rbp),%rsi
call   1030 <hex2bin@plt>
lea    -0x1b0(%rbp),%rdi
lea    -0x1e0(%rbp),%rsi
mov    $0x10,%edx
call   1050 <memcmp@plt>
mov    %rax,%rdx
mov    $0x5,%eax
xor    %ecx,%ecx
cmp    $0x0,%rdx
cmove  %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x1c8,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x100(%rsp),%rdi
xor    %esi,%esi
mov    $0xc8,%edx
call   1040 <memset@plt>
lea    0x30(%rsp),%rdi
xor    %esi,%esi
mov    $0xc8,%edx
call   1040 <memset@plt>
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x11,%edx
call   1040 <memset@plt>
mov    $0x4,%eax
cmp    $0x4,%ebp
jne    121a <main+0xca>
mov    0x8(%rbx),%r14
mov    0x10(%rbx),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0x10,%edx
call   1060 <memcpy@plt>
mov    0x18(%rbx),%rsi
lea    0x100(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x10,%edx
call   1060 <memcpy@plt>
lea    0x30(%rsp),%rbp
mov    %r15,%rdi
mov    $0x1,%esi
mov    %rbp,%rdx
mov    %rbx,%rcx
mov    $0xc8,%r8d
call   1070 <TDES@plt>
lea    0x20(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <hex2bin@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x10,%edx
call   1050 <memcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    (%rcx,%rcx,4),%eax
add    $0x1c8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [200 x i8]
%7 = alloca [200 x i8]
%8 = alloca [17 x i8]
%9 = alloca [16 x i8]
%10 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%12 = call i32 @memset(i8* %11, i32 0, i32 200)
%13 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%14 = call i32 @memset(i8* %13, i32 0, i32 200)
%15 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 0
%16 = call i32 @memset(i8* %15, i32 0, i32 17)
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 4
br i1 %18, label %19, label %20
19: ; preds = %2
store i32 4, i32* %3
br label %47
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
store i8* %23, i8** %10
%24 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 0
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @memcpy(i8* %24, i8* %27, i32 16)
%29 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 3
%32 = load i8*, i8** %31
%33 = call i32 @memcpy(i8* %29, i8* %32, i32 16)
%34 = getelementptr inbounds [17 x i8], [17 x i8]* %8, i64 0, i64 0
%35 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%36 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%37 = call i32 @TDES(i8* %34, i32 1, i8* %35, i8* %36, i32 200)
%38 = load i8*, i8** %10
%39 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%40 = call i32 @hex2bin(i8* %38, i8* %39)
%41 = getelementptr inbounds [200 x i8], [200 x i8]* %7, i64 0, i64 0
%42 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%43 = call i64 @memcmp(i8* %41, i8* %42, i32 16)
%44 = icmp eq i64 %43, 0
%45 = zext i1 %44 to i64
%46 = select i1 %44, i32 0, i32 5
store i32 %46, i32* %3
br label %47
47: ; preds = %20, %19
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [200 x i8]
%4 = alloca [200 x i8]
%5 = alloca [17 x i8]
%6 = alloca [16 x i8]
%7 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [17 x i8], [17 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %6, i64 0, i64 0
%11 = call i32 @memset(i8* %7, i32 0, i32 200)
%12 = call i32 @memset(i8* %8, i32 0, i32 200)
%13 = call i32 @memset(i8* %9, i32 0, i32 17)
%14 = icmp eq i32 %0, 4
br i1 %14, label %15, label %29
15: ; preds = %2
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = call i32 @memcpy(i8* %9, i8* %19, i32 16)
%21 = getelementptr inbounds i8*, i8** %1, i64 3
%22 = load i8*, i8** %21
%23 = call i32 @memcpy(i8* %7, i8* %22, i32 16)
%24 = call i32 @TDES(i8* %9, i32 1, i8* %8, i8* %7, i32 200)
%25 = call i32 @hex2bin(i8* %17, i8* %10)
%26 = call i64 @memcmp(i8* %8, i8* %10, i32 16)
%27 = icmp eq i64 %26, 0
%28 = select i1 %27, i32 0, i32 5
br label %29
29: ; preds = %2, %15
%30 = phi i32 [ %28, %15 ], [ 4, %2 ]
ret i32 %30
}