#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*/ BINARY_DIFF(unsigned char *, unsigned char *, int,
                               unsigned char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int get_bkey_from_str(char *, unsigned char *);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ safe_hexatostr(unsigned char *, int, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ stderr;
main() {
  char str1[128];
  char str2[128];
  char strd[128];
  unsigned char bkey1[32];
  unsigned char bkey2[32];
  unsigned char bkeyd[32];
  int nbkey1, nbkey2;
  sprintf(str1, "%s", "0x2780FA1D");
  sprintf(str2, "%s", "0x1784FA0F");
  fprintf(stderr, "\tstr1=%s\n", str1);
  fprintf(stderr, "\tstr2=%s\n", str2);
  nbkey1 = get_bkey_from_str(str1, bkey1);
  if (nbkey1 == -1) {
    fprintf(stderr, "get_bkey_from_str error");
    exit(1);
  }
  nbkey2 = get_bkey_from_str(str2, bkey2);
  if (nbkey2 == -1) {
    fprintf(stderr, "get_bkey_from_str error");
    exit(1);
  }
  if (nbkey1 != nbkey2) {
    fprintf(stderr, "nbkey is diffrent.");
    exit(1);
  }
  BINARY_DIFF(bkey1, bkey2, nbkey1, bkeyd);
  memcpy(strd, "0x", 2);
  safe_hexatostr(bkeyd, nbkey1, strd + 2);
  fprintf(stderr, "\tstrd=%s\n", strd);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1f0,%rsp
lea    -0x80(%rbp),%rdi
lea    0xe7a(%rip),%rsi
lea    0xe76(%rip),%rdx
call   1070 <sprintf@plt>
lea    -0x100(%rbp),%rdi
lea    0xe60(%rip),%rsi
lea    0xe67(%rip),%rdx
call   1070 <sprintf@plt>
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
lea    -0x80(%rbp),%rdx
lea    0xe59(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
lea    -0x100(%rbp),%rdx
lea    0xe45(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
lea    -0x80(%rbp),%rdi
lea    -0x1a0(%rbp),%rsi
call   1040 <get_bkey_from_str@plt>
mov    %eax,-0x1e4(%rbp)
cmpl   $0xffffffff,-0x1e4(%rbp)
jne    1229 <main+0xb9>
mov    0x2dd1(%rip),%rax
mov    (%rax),%edi
lea    0xe15(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    -0x100(%rbp),%rdi
lea    -0x1c0(%rbp),%rsi
call   1040 <get_bkey_from_str@plt>
mov    %eax,-0x1e8(%rbp)
cmpl   $0xffffffff,-0x1e8(%rbp)
jne    1270 <main+0x100>
mov    0x2d8a(%rip),%rax
mov    (%rax),%edi
lea    0xdce(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x1e4(%rbp),%eax
cmp    -0x1e8(%rbp),%eax
je     12a3 <main+0x133>
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
lea    0xdb3(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    -0x1a0(%rbp),%rdi
lea    -0x1c0(%rbp),%rsi
mov    -0x1e4(%rbp),%edx
lea    -0x1e0(%rbp),%rcx
call   1090 <BINARY_DIFF@plt>
lea    -0x180(%rbp),%rdi
lea    0xd87(%rip),%rsi
mov    $0x2,%edx
call   1060 <memcpy@plt>
lea    -0x1e0(%rbp),%rdi
mov    -0x1e4(%rbp),%esi
lea    -0x180(%rbp),%rdx
add    $0x2,%rdx
call   1030 <safe_hexatostr@plt>
mov    0x2ce1(%rip),%rax
mov    (%rax),%edi
lea    -0x180(%rbp),%rdx
lea    0xd4c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x1f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x1e8,%rsp
movabs $0x4146303837327830,%rax
30 46 41
mov    %rax,0xe0(%rsp)
movl   $0x443141,0xe7(%rsp)
movabs $0x4146343837317830,%rax
34 46 41
mov    %rax,0x60(%rsp)
movl   $0x463041,0x67(%rsp)
mov    0x2e37(%rip),%r12
mov    (%r12),%edi
lea    0xe62(%rip),%rsi
lea    0xe0(%rsp),%rbx
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r12),%edi
lea    0xe4f(%rip),%rsi
lea    0x60(%rsp),%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <get_bkey_from_str@plt>
cmp    $0xffffffff,%eax
je     1276 <main+0x116>
mov    %eax,%ebx
lea    0x60(%rsp),%rdi
mov    %rsp,%rsi
call   1040 <get_bkey_from_str@plt>
cmp    $0xffffffff,%eax
je     1276 <main+0x116>
cmp    %eax,%ebx
jne    1283 <main+0x123>
lea    0x20(%rsp),%rdi
mov    %rsp,%rsi
lea    0x40(%rsp),%r14
mov    %ebx,%edx
mov    %r14,%rcx
call   1080 <BINARY_DIFF@plt>
lea    0xe2c(%rip),%rsi
lea    0x160(%rsp),%r15
mov    %r15,%rdi
mov    $0x2,%edx
call   1060 <memcpy@plt>
lea    0x162(%rsp),%rdx
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <safe_hexatostr@plt>
mov    (%r12),%edi
lea    0xdfd(%rip),%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x1e8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    (%r12),%edi
lea    0xda9(%rip),%rsi
jmp    128e <main+0x12e>
mov    (%r12),%edi
lea    0xdb4(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [11 x i8] c"0x2780FA1D\00"
@.str.2 = [11 x i8] c"0x1784FA0F\00"
@stderr = global i32 0
@.str.3 = [10 x i8] c"\09str1=%s\0A\00"
@.str.4 = [10 x i8] c"\09str2=%s\0A\00"
@.str.5 = [24 x i8] c"get_bkey_from_str error\00"
@.str.6 = [19 x i8] c"nbkey is diffrent.\00"
@.str.7 = [3 x i8] c"0x\00"
@.str.8 = [10 x i8] c"\09strd=%s\0A\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = alloca [128 x i8]
%3 = alloca [128 x i8]
%4 = alloca [32 x i8]
%5 = alloca [32 x i8]
%6 = alloca [32 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%10 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%12 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%13 = load i32, i32* @stderr
%14 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @stderr
%17 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %17)
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%20 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%21 = call i32 @get_bkey_from_str(i8* %19, i8* %20)
store i32 %21, i32* %7
%22 = load i32, i32* %7
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %28
24: ; preds = %0
%25 = load i32, i32* @stderr
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %25, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %0
%29 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%30 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%31 = call i32 @get_bkey_from_str(i8* %29, i8* %30)
store i32 %31, i32* %8
%32 = load i32, i32* %8
%33 = icmp eq i32 %32, -1
br i1 %33, label %34, label %38
34: ; preds = %28
%35 = load i32, i32* @stderr
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %28
%39 = load i32, i32* %7
%40 = load i32, i32* %8
%41 = icmp ne i32 %39, %40
br i1 %41, label %42, label %46
42: ; preds = %38
%43 = load i32, i32* @stderr
%44 = call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %38
%47 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%48 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%49 = load i32, i32* %7
%50 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%51 = call i32 @BINARY_DIFF(i8* %47, i8* %48, i32 %49, i8* %50)
%52 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%53 = call i32 @memcpy(i8* %52, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 2)
%54 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%55 = load i32, i32* %7
%56 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%57 = getelementptr inbounds i8, i8* %56, i64 2
%58 = call i32 @safe_hexatostr(i8* %54, i32 %55, i8* %57)
%59 = load i32, i32* @stderr
%60 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8* %60)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [11 x i8] c"0x2780FA1D\00"
@.str.2 = [11 x i8] c"0x1784FA0F\00"
@stderr = global i32 0
@.str.3 = [10 x i8] c"\09str1=%s\0A\00"
@.str.4 = [10 x i8] c"\09str2=%s\0A\00"
@.str.5 = [24 x i8] c"get_bkey_from_str error\00"
@.str.6 = [19 x i8] c"nbkey is diffrent.\00"
@.str.7 = [3 x i8] c"0x\00"
@.str.8 = [10 x i8] c"\09strd=%s\0A\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = alloca [128 x i8]
%3 = alloca [128 x i8]
%4 = alloca [32 x i8]
%5 = alloca [32 x i8]
%6 = alloca [32 x i8]
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%13 = load i32, i32* @stderr
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %7)
%15 = load i32, i32* @stderr
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8* %8)
%17 = call i32 @get_bkey_from_str(i8* %7, i8* %10)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %23
19: ; preds = %0
%20 = load i32, i32* @stderr
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %0
%24 = call i32 @get_bkey_from_str(i8* %8, i8* %11)
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %30
26: ; preds = %23
%27 = load i32, i32* @stderr
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %23
%31 = icmp eq i32 %17, %24
br i1 %31, label %36, label %32
32: ; preds = %30
%33 = load i32, i32* @stderr
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %30
%37 = call i32 @BINARY_DIFF(i8* %10, i8* %11, i32 %17, i8* %12)
%38 = call i32 @memcpy(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 2)
%39 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 2
%40 = call i32 @safe_hexatostr(i8* %12, i32 %17, i8* %39)
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.8, i64 0, i64 0), i8* %9)
ret i32 0
}