#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 *, ...);
int /*<<< orphan*/ puts(char *);
unsigned int strtoul(char *, long, int);
int main(int argc, char **argv) {
  if (argc != 3) {
    printf("Usage: %s <num1> <num2>\n");
    return 0;
  }
  unsigned int x = strtoul(argv[1], 0L, 10);
  unsigned int y = strtoul(argv[2], 0L, 10);
  unsigned int bak = x;
  unsigned int sum, carry;
  sum = x ^ y;
  carry = x & y;
  while (carry != 0) {
    carry = carry << 1;
    x = sum;
    y = carry;
    sum = x ^ y;
    carry = x & y;
  }
  if (bak == 1337 && sum == 13377331) {
    printf("Flag: HCL8{The_magical_number_is_%d}\n", y);
  } else {
    puts("Nope.");
  }
  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   $0x3,-0x8(%rbp)
je     116a <main+0x3a>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    122d <main+0xfd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtoul@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1050 <strtoul@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
xor    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
and    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11ea <main+0xba>
mov    -0x24(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
xor    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
and    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    11b4 <main+0x84>
cmpl   $0x539,-0x1c(%rbp)
jne    121a <main+0xea>
cmpl   $0xcc1f33,-0x20(%rbp)
jne    121a <main+0xea>
mov    -0x18(%rbp),%esi
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1226 <main+0xf6>
lea    0xe1e(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    11a2 <main+0x72>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtoul@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtoul@plt>
mov    %eax,%ecx
xor    %ebp,%ecx
mov    %eax,%edx
and    %ebp,%edx
je     1180 <main+0x50>
mov    %ecx,%esi
nopl   0x0(%rax)
mov    %edx,%eax
add    %edx,%eax
mov    %eax,%ecx
xor    %esi,%ecx
and    %eax,%esi
mov    %esi,%edx
mov    %ecx,%esi
jne    1170 <main+0x40>
cmp    $0x539,%ebp
jne    11b2 <main+0x82>
cmp    $0xcc1f33,%ecx
jne    11b2 <main+0x82>
lea    0xe82(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11be <main+0x8e>
lea    0xe57(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11be <main+0x8e>
lea    0xe86(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"Usage: %s <num1> <num2>\0A\00"
@.str.1 = [38 x i8] c"Flag: HCL8{The_magical_number_is_%d}\0A\00"
@.str.2 = [6 x i8] c"Nope.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 3
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %57
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @strtoul(i8* %18, i64 0, i32 10)
store i32 %19, i32* %6
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 2
%22 = load i8*, i8** %21
%23 = call i32 @strtoul(i8* %22, i64 0, i32 10)
store i32 %23, i32* %7
%24 = load i32, i32* %6
store i32 %24, i32* %8
%25 = load i32, i32* %6
%26 = load i32, i32* %7
%27 = xor i32 %25, %26
store i32 %27, i32* %9
%28 = load i32, i32* %6
%29 = load i32, i32* %7
%30 = and i32 %28, %29
store i32 %30, i32* %10
br label %31
31: ; preds = %34, %15
%32 = load i32, i32* %10
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %45
34: ; preds = %31
%35 = load i32, i32* %10
%36 = shl i32 %35, 1
store i32 %36, i32* %10
%37 = load i32, i32* %9
store i32 %37, i32* %6
%38 = load i32, i32* %10
store i32 %38, i32* %7
%39 = load i32, i32* %6
%40 = load i32, i32* %7
%41 = xor i32 %39, %40
store i32 %41, i32* %9
%42 = load i32, i32* %6
%43 = load i32, i32* %7
%44 = and i32 %42, %43
store i32 %44, i32* %10
br label %31
45: ; preds = %31
%46 = load i32, i32* %8
%47 = icmp eq i32 %46, 1337
br i1 %47, label %48, label %54
48: ; preds = %45
%49 = load i32, i32* %9
%50 = icmp eq i32 %49, 13377331
br i1 %50, label %51, label %54
51: ; preds = %48
%52 = load i32, i32* %7
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %52)
br label %56
54: ; preds = %48, %45
%55 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %56
56: ; preds = %54, %51
store i32 0, i32* %3
br label %57
57: ; preds = %56, %13
%58 = load i32, i32* %3
ret i32 %58
}

LLVM IR (-O2):
@.str = [25 x i8] c"Usage: %s <num1> <num2>\0A\00"
@.str.1 = [38 x i8] c"Flag: HCL8{The_magical_number_is_%d}\0A\00"
@.str.2 = [6 x i8] c"Nope.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %33
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @strtoul(i8* %8, i64 0, i32 10)
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @strtoul(i8* %11, i64 0, i32 10)
%13 = xor i32 %12, %9
%14 = and i32 %12, %9
%15 = icmp eq i32 %14, 0
br i1 %15, label %23, label %16
16: ; preds = %6, %16
%17 = phi i32 [ %21, %16 ], [ %14, %6 ]
%18 = phi i32 [ %20, %16 ], [ %13, %6 ]
%19 = shl i32 %17, 1
%20 = xor i32 %19, %18
%21 = and i32 %19, %18
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %16
23: ; preds = %16, %6
%24 = phi i32 [ %12, %6 ], [ %19, %16 ]
%25 = phi i32 [ %13, %6 ], [ %20, %16 ]
%26 = icmp eq i32 %9, 1337
%27 = icmp eq i32 %25, 13377331
%28 = select i1 %26, i1 %27, i1 false
br i1 %28, label %29, label %31
29: ; preds = %23
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %24)
br label %33
31: ; preds = %23
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %33
33: ; preds = %29, %31, %4
ret i32 0
}