#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 pow(unsigned int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, unsigned int *);
int main() {
  unsigned int uid = 1;
  while (uid != 0) {
    printf("Please enter UID: ");
    scanf("%d", &uid);
    unsigned int key = 0;
    key = ((pow(uid, 2)) / 10000000);
    key %= 1000;
    printf("%d : %d\n", uid, key);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11b5 <main+0x85>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeae(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x2,%esi
call   1050 <pow@plt>
mov    $0x989680,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x3e8,%ecx
xor    %edx,%edx
div    %ecx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1146 <main+0x16>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
movl   $0x1,0x4(%rsp)
lea    0xeb9(%rip),%r14
lea    0xec5(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xebc(%rip),%rbx
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%edi
mov    $0x2,%esi
call   1050 <pow@plt>
cltq
imul   $0x6b5fca6b,%rax,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x36,%rdx
add    %eax,%edx
imul   $0x10624dd3,%rdx,%rax
shr    $0x26,%rax
imul   $0x3e8,%eax,%eax
sub    %eax,%edx
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmpl   $0x0,0x4(%rsp)
jne    1160 <main+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Please enter UID: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [9 x i8] c"%d : %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
br label %4
4: ; preds = %7, %0
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %18
7: ; preds = %4
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 0, i32* %3
%10 = load i32, i32* %2
%11 = call i32 @pow(i32 %10, i32 2)
%12 = sdiv i32 %11, 10000000
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = urem i32 %13, 1000
store i32 %14, i32* %3
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %15, i32 %16)
br label %4
18: ; preds = %4
ret i32 0
}

LLVM IR (-O2):
@.str = [19 x i8] c"Please enter UID: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [9 x i8] c"%d : %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 1, i32* %1
br label %3
3: ; preds = %0, %3
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = call i32 @pow(i32 %6, i32 2)
%8 = sdiv i32 %7, 10000000
%9 = urem i32 %8, 1000
%10 = load i32, i32* %1
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %10, i32 %9)
%12 = load i32, i32* %1
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %3
14: ; preds = %3
ret i32 0
}