#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, unsigned int);
int sscanf(char *, char *, unsigned int *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  unsigned int trknum = 1;
  unsigned int discid;
  char dummy;
  if (argc != 3) {
    fprintf(
        stderr,
        "Please invoke as 'mp3key <tracknum> <discid>'\n"
        "where tracknum is a decimal track number and discid is the last 8\n"
        "digits (4 bytes) of the hex disc id\n");
    return 1;
  }
  if (sscanf(argv[1], "%d%c", &trknum, &dummy) != 1) {
    fprintf(stderr, "Track number is not a decimal integer\n");
    return 1;
  }
  if (sscanf(argv[2], "%x%c", &discid, &dummy) != 1) {
    fprintf(stderr, "Disk ID is not an 8 digit hex string\n");
    return 1;
  }
  unsigned int foo = ((trknum * 0x6953B2ED) + 0x6BAAB1) ^ discid;
  printf("%08X\n", foo & 0xFFFFFFFF);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1178 <main+0x48>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
lea    0xe99(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    122f <main+0xff>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xf0e(%rip),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x19(%rbp),%rcx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
je     11be <main+0x8e>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xeed(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    122f <main+0xff>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xef4(%rip),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x19(%rbp),%rcx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
je     1204 <main+0xd4>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
lea    0xed3(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    122f <main+0xff>
imul   $0x6953b2ed,-0x14(%rbp),%eax
add    $0x6baab1,%eax
xor    -0x18(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
and    $0xffffffff,%esi
lea    0xec9(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x1,0x8(%rsp)
cmp    $0x3,%edi
jne    11a5 <main+0x75>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xf45(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0x7(%rsp),%rcx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
jne    11b7 <main+0x87>
mov    0x10(%rbx),%rdi
lea    0xf52(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x7(%rsp),%rcx
call   1050 <sscanf@plt>
cmp    $0x1,%eax
jne    11c9 <main+0x99>
imul   $0x6953b2ed,0x8(%rsp),%esi
69
add    $0x6baab1,%esi
xor    0xc(%rsp),%esi
lea    0xf50(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
jmp    11e3 <main+0xb3>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
lea    0xe4b(%rip),%rsi
jmp    11d9 <main+0xa9>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
lea    0xed3(%rip),%rsi
jmp    11d9 <main+0xa9>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
lea    0xeed(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [149 x i8] c"Please invoke as 'mp3key <tracknum> <discid>'\0Awhere tracknum is a decimal track number and discid is the last 8\0Adigits (4 bytes) of the hex disc id\0A\00"
@.str.1 = [5 x i8] c"%d%c\00"
@.str.2 = [39 x i8] c"Track number is not a decimal integer\0A\00"
@.str.3 = [5 x i8] c"%x%c\00"
@.str.4 = [38 x i8] c"Disk ID is not an 8 digit hex string\0A\00"
@.str.5 = [6 x i8] c"%08X\0A\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 i8
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 3
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %42
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %6, i8* %8)
%20 = icmp ne i32 %19, 1
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %42
24: ; preds = %15
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @sscanf(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32* %7, i8* %8)
%29 = icmp ne i32 %28, 1
br i1 %29, label %30, label %33
30: ; preds = %24
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %42
33: ; preds = %24
%34 = load i32, i32* %6
%35 = mul i32 %34, 1767092973
%36 = add i32 %35, 7056049
%37 = load i32, i32* %7
%38 = xor i32 %36, %37
store i32 %38, i32* %9
%39 = load i32, i32* %9
%40 = and i32 %39, -1
%41 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %40)
store i32 0, i32* %3
br label %42
42: ; preds = %33, %30, %21, %12
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [149 x i8] c"Please invoke as 'mp3key <tracknum> <discid>'\0Awhere tracknum is a decimal track number and discid is the last 8\0Adigits (4 bytes) of the hex disc id\0A\00"
@.str.1 = [5 x i8] c"%d%c\00"
@.str.2 = [39 x i8] c"Track number is not a decimal integer\0A\00"
@.str.3 = [5 x i8] c"%x%c\00"
@.str.4 = [38 x i8] c"Disk ID is not an 8 digit hex string\0A\00"
@.str.5 = [6 x i8] c"%08X\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = bitcast i32* %3 to i8*
store i32 1, i32* %3
%7 = bitcast i32* %4 to i8*
%8 = icmp eq i32 %0, 3
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([149 x i8], [149 x i8]* @.str, i64 0, i64 0))
br label %35
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %3, i8* %5)
%16 = icmp eq i32 %15, 1
br i1 %16, label %20, label %17
17: ; preds = %12
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
br label %35
20: ; preds = %12
%21 = getelementptr inbounds i8*, i8** %1, i64 2
%22 = load i8*, i8** %21
%23 = call i32 @sscanf(i8* %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32* %4, i8* %5)
%24 = icmp eq i32 %23, 1
br i1 %24, label %28, label %25
25: ; preds = %20
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
br label %35
28: ; preds = %20
%29 = load i32, i32* %3
%30 = mul i32 %29, 1767092973
%31 = add i32 %30, 7056049
%32 = load i32, i32* %4
%33 = xor i32 %31, %32
%34 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %28, %25, %17, %9
%36 = phi i32 [ 1, %9 ], [ 1, %17 ], [ 1, %25 ], [ 0, %28 ]
ret i32 %36
}