#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*/ printf(char *, unsigned long, unsigned long, ...);
int sscanf(char *, char *, unsigned int *, unsigned int *, unsigned int *,
           unsigned int *, unsigned int *, unsigned int *, unsigned int *,
           unsigned int *);
int /*<<< orphan*/ tea_enc(unsigned long *, unsigned long *);
int main(int argc, char *argv[]) {
  unsigned int ibuf[8];
  unsigned long block[2],
      key[4] = {0x01234567, 0x89ABCDEF, 0x01234567, 0x89ABCDEF};
  int ret, i;
  if (argc != 2)
    return 1;
  ret = sscanf(argv[1], "%2X%2X%2X%2X%2X%2X%2X%2X", &ibuf[0], &ibuf[1],
               &ibuf[2], &ibuf[3], &ibuf[4], &ibuf[5], &ibuf[6], &ibuf[7]);
  if (ret != 8)
    return 2;
  block[0] = ((ibuf[0] & 0xFF) << 24) | ((ibuf[1] & 0xFF) << 16) |
             ((ibuf[2] & 0xFF) << 8) | ((ibuf[3] & 0xFF));
  block[1] = ((ibuf[4] & 0xFF) << 24) | ((ibuf[5] & 0xFF) << 16) |
             ((ibuf[6] & 0xFF) << 8) | ((ibuf[7] & 0xFF));
  printf("Key: %.8X %.8X %.8X %.8X\n", key[0], key[1], key[2], key[3]);
  printf("Challenge: %.8X %.8X\n", block[0], block[1]);
  tea_enc(block, key);
  printf("Response: %.8X %.8X\n", block[0], block[1]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x98,%rsp
movl   $0x0,-0xc(%rbp)
mov    %edi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    0xeaf(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xeac(%rip),%rax
mov    %rax,-0x68(%rbp)
mov    0xea9(%rip),%rax
mov    %rax,-0x60(%rbp)
mov    0xea6(%rip),%rax
mov    %rax,-0x58(%rbp)
cmpl   $0x2,-0x10(%rbp)
je     118c <main+0x5c>
movl   $0x1,-0xc(%rbp)
jmp    12d6 <main+0x1a6>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x40(%rbp),%rdx
lea    -0x40(%rbp),%rcx
add    $0x4,%rcx
lea    -0x40(%rbp),%r8
add    $0x8,%r8
lea    -0x40(%rbp),%r9
add    $0xc,%r9
lea    -0x40(%rbp),%rbx
add    $0x10,%rbx
lea    -0x40(%rbp),%r11
add    $0x14,%r11
lea    -0x40(%rbp),%r10
add    $0x18,%r10
lea    -0x40(%rbp),%rax
add    $0x1c,%rax
lea    0xe49(%rip),%rsi
mov    %rbx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10,0x10(%rsp)
mov    %rax,0x18(%rsp)
call   1050 <sscanf@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0x8,-0x74(%rbp)
je     1208 <main+0xd8>
movl   $0x2,-0xc(%rbp)
jmp    12d6 <main+0x1a6>
mov    -0x40(%rbp),%eax
and    $0xff,%eax
shl    $0x18,%eax
mov    -0x3c(%rbp),%ecx
and    $0xff,%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x38(%rbp),%ecx
and    $0xff,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x34(%rbp),%ecx
and    $0xff,%ecx
or     %ecx,%eax
mov    %eax,%eax
mov    %rax,-0x50(%rbp)
mov    -0x30(%rbp),%eax
and    $0xff,%eax
shl    $0x18,%eax
mov    -0x2c(%rbp),%ecx
and    $0xff,%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x28(%rbp),%ecx
and    $0xff,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x24(%rbp),%ecx
and    $0xff,%ecx
or     %ecx,%eax
mov    %eax,%eax
mov    %rax,-0x48(%rbp)
mov    -0x70(%rbp),%rsi
mov    -0x68(%rbp),%rdx
mov    -0x60(%rbp),%rcx
mov    -0x58(%rbp),%r8
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x50(%rbp),%rsi
mov    -0x48(%rbp),%rdx
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x50(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1040 <tea_enc@plt>
mov    -0x50(%rbp),%rsi
mov    -0x48(%rbp),%rdx
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x98,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
movaps 0xed0(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xeb4(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
mov    $0x1,%ebx
cmp    $0x2,%edi
jne    126c <main+0x13c>
mov    0x8(%rsi),%rdi
lea    0x4(%rsp),%rcx
lea    0x8(%rsp),%r8
lea    0xc(%rsp),%r9
lea    0x10(%rsp),%r10
lea    0x14(%rsp),%r11
lea    0x18(%rsp),%rax
lea    0x1c(%rsp),%rbx
lea    0xe93(%rip),%rsi
mov    %rsp,%rdx
push   %rbx
push   %rax
push   %r11
push   %r10
call   1050 <sscanf@plt>
add    $0x20,%rsp
mov    $0x2,%ebx
cmp    $0x8,%eax
jne    126c <main+0x13c>
mov    (%rsp),%eax
mov    0x4(%rsp),%ecx
shl    $0x18,%eax
movzbl %cl,%ecx
shl    $0x10,%rcx
or     %rcx,%rax
mov    0x8(%rsp),%ecx
shl    $0x8,%ecx
movzwl %cx,%ecx
or     %rax,%rcx
movzbl 0xc(%rsp),%r14d
or     %rcx,%r14
mov    %r14,0x20(%rsp)
mov    0x10(%rsp),%eax
shl    $0x18,%eax
mov    0x14(%rsp),%ecx
movzbl %cl,%ecx
shl    $0x10,%rcx
or     %rcx,%rax
mov    0x18(%rsp),%ecx
shl    $0x8,%ecx
movzwl %cx,%ecx
or     %rax,%rcx
movzbl 0x1c(%rsp),%r15d
or     %rcx,%r15
mov    %r15,0x28(%rsp)
lea    0xe26(%rip),%rdi
xor    %ebx,%ebx
mov    $0x1234567,%esi
mov    $0x89abcdef,%edx
mov    $0x1234567,%ecx
mov    $0x89abcdef,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe1b(%rip),%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x20(%rsp),%rdi
lea    0x30(%rsp),%rsi
call   1040 <tea_enc@plt>
mov    0x20(%rsp),%rsi
mov    0x28(%rsp),%rdx
lea    0xe04(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.key = [4 x i64] [i64 19088743, i64 2309737967, i64 19088743, i64 2309737967]
@.str = [25 x i8] c"%2X%2X%2X%2X%2X%2X%2X%2X\00"
@.str.1 = [26 x i8] c"Key: %.8X %.8X %.8X %.8X\0A\00"
@.str.2 = [22 x i8] c"Challenge: %.8X %.8X\0A\00"
@.str.3 = [21 x i8] c"Response: %.8X %.8X\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [8 x i32]
%7 = alloca [2 x i64]
%8 = alloca [4 x i64]
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = bitcast [4 x i64]* %8 to i8*
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 1, i32* %3
br label %94
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 0
%20 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 1
%21 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 2
%22 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 3
%23 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 4
%24 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 5
%25 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 6
%26 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 7
%27 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32* %19, i32* %20, i32* %21, i32* %22, i32* %23, i32* %24, i32* %25, i32* %26)
store i32 %27, i32* %9
%28 = load i32, i32* %9
%29 = icmp ne i32 %28, 8
br i1 %29, label %30, label %31
30: ; preds = %15
store i32 2, i32* %3
br label %94
31: ; preds = %15
%32 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 0
%33 = load i32, i32* %32
%34 = and i32 %33, 255
%35 = shl i32 %34, 24
%36 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 1
%37 = load i32, i32* %36
%38 = and i32 %37, 255
%39 = shl i32 %38, 16
%40 = or i32 %35, %39
%41 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 2
%42 = load i32, i32* %41
%43 = and i32 %42, 255
%44 = shl i32 %43, 8
%45 = or i32 %40, %44
%46 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 3
%47 = load i32, i32* %46
%48 = and i32 %47, 255
%49 = or i32 %45, %48
%50 = zext i32 %49 to i64
%51 = getelementptr inbounds [2 x i64], [2 x i64]* %7, i64 0, i64 0
store i64 %50, i64* %51
%52 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 4
%53 = load i32, i32* %52
%54 = and i32 %53, 255
%55 = shl i32 %54, 24
%56 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 5
%57 = load i32, i32* %56
%58 = and i32 %57, 255
%59 = shl i32 %58, 16
%60 = or i32 %55, %59
%61 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 6
%62 = load i32, i32* %61
%63 = and i32 %62, 255
%64 = shl i32 %63, 8
%65 = or i32 %60, %64
%66 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 7
%67 = load i32, i32* %66
%68 = and i32 %67, 255
%69 = or i32 %65, %68
%70 = zext i32 %69 to i64
%71 = getelementptr inbounds [2 x i64], [2 x i64]* %7, i64 0, i64 1
store i64 %70, i64* %71
%72 = getelementptr inbounds [4 x i64], [4 x i64]* %8, i64 0, i64 0
%73 = load i64, i64* %72
%74 = getelementptr inbounds [4 x i64], [4 x i64]* %8, i64 0, i64 1
%75 = load i64, i64* %74
%76 = getelementptr inbounds [4 x i64], [4 x i64]* %8, i64 0, i64 2
%77 = load i64, i64* %76
%78 = getelementptr inbounds [4 x i64], [4 x i64]* %8, i64 0, i64 3
%79 = load i64, i64* %78
%80 = call i32 (i8*, i64, i64, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i64 %73, i64 %75, i64 %77, i64 %79)
%81 = getelementptr inbounds [2 x i64], [2 x i64]* %7, i64 0, i64 0
%82 = load i64, i64* %81
%83 = getelementptr inbounds [2 x i64], [2 x i64]* %7, i64 0, i64 1
%84 = load i64, i64* %83
%85 = call i32 (i8*, i64, i64, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i64 %82, i64 %84)
%86 = getelementptr inbounds [2 x i64], [2 x i64]* %7, i64 0, i64 0
%87 = getelementptr inbounds [4 x i64], [4 x i64]* %8, i64 0, i64 0
%88 = call i32 @tea_enc(i64* %86, i64* %87)
%89 = getelementptr inbounds [2 x i64], [2 x i64]* %7, i64 0, i64 0
%90 = load i64, i64* %89
%91 = getelementptr inbounds [2 x i64], [2 x i64]* %7, i64 0, i64 1
%92 = load i64, i64* %91
%93 = call i32 (i8*, i64, i64, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i64 %90, i64 %92)
store i32 0, i32* %3
br label %94
94: ; preds = %31, %30, %14
%95 = load i32, i32* %3
ret i32 %95
}

LLVM IR (-O2):
@__const.main.key = [4 x i64] [i64 19088743, i64 2309737967, i64 19088743, i64 2309737967]
@.str = [25 x i8] c"%2X%2X%2X%2X%2X%2X%2X%2X\00"
@.str.1 = [26 x i8] c"Key: %.8X %.8X %.8X %.8X\0A\00"
@.str.2 = [22 x i8] c"Challenge: %.8X %.8X\0A\00"
@.str.3 = [21 x i8] c"Response: %.8X %.8X\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [8 x i32]
%4 = alloca [2 x i64]
%5 = alloca [4 x i64]
%6 = bitcast [8 x i32]* %3 to i8*
%7 = bitcast [2 x i64]* %4 to i8*
%8 = bitcast [4 x i64]* %5 to i8*
%9 = icmp eq i32 %0, 2
br i1 %9, label %10, label %61
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 0
%14 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 1
%15 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 2
%16 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 3
%17 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 4
%18 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 5
%19 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 6
%20 = getelementptr inbounds [8 x i32], [8 x i32]* %3, i64 0, i64 7
%21 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32* %13, i32* %14, i32* %15, i32* %16, i32* %17, i32* %18, i32* %19, i32* %20)
%22 = icmp eq i32 %21, 8
br i1 %22, label %23, label %61
23: ; preds = %10
%24 = load i32, i32* %13
%25 = shl i32 %24, 24
%26 = load i32, i32* %14
%27 = shl i32 %26, 16
%28 = and i32 %27, 16711680
%29 = or i32 %28, %25
%30 = load i32, i32* %15
%31 = shl i32 %30, 8
%32 = and i32 %31, 65280
%33 = or i32 %29, %32
%34 = load i32, i32* %16
%35 = and i32 %34, 255
%36 = or i32 %33, %35
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds [2 x i64], [2 x i64]* %4, i64 0, i64 0
store i64 %37, i64* %38
%39 = load i32, i32* %17
%40 = shl i32 %39, 24
%41 = load i32, i32* %18
%42 = shl i32 %41, 16
%43 = and i32 %42, 16711680
%44 = or i32 %43, %40
%45 = load i32, i32* %19
%46 = shl i32 %45, 8
%47 = and i32 %46, 65280
%48 = or i32 %44, %47
%49 = load i32, i32* %20
%50 = and i32 %49, 255
%51 = or i32 %48, %50
%52 = zext i32 %51 to i64
%53 = getelementptr inbounds [2 x i64], [2 x i64]* %4, i64 0, i64 1
store i64 %52, i64* %53
%54 = getelementptr inbounds [4 x i64], [4 x i64]* %5, i64 0, i64 0
%55 = call i32 (i8*, i64, i64, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i64 19088743, i64 2309737967, i64 19088743, i64 2309737967)
%56 = call i32 (i8*, i64, i64, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i64 %37, i64 %52)
%57 = call i32 @tea_enc(i64* %38, i64* %54)
%58 = load i64, i64* %38
%59 = load i64, i64* %53
%60 = call i32 (i8*, i64, i64, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i64 %58, i64 %59)
br label %61
61: ; preds = %10, %2, %23
%62 = phi i32 [ 0, %23 ], [ 1, %2 ], [ 2, %10 ]
ret i32 %62
}