#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 int, ...);
int main() {
  unsigned int a = 1 << 20;
  unsigned int b = 0 - a;
  printf("a=%u\n", a);
  printf("a=0x%x\n", a);
  printf("b=%u\n", b);
  printf("b=0x%x\n", b);
  a = 1;
  b = 2;
  unsigned int c = a - b;
  printf("1-2=%x\n", c);
  c = b - a;
  printf("2-1=%x\n", c);
  a = 0x3f914584;
  b = 0xffffffff;
  c = a - b;
  printf("%x-%x=%x\n", a, b, c);
  a = 0x3f914584;
  b = 0x3f914585;
  c = a + b;
  printf("%x+%x=%x\n", a, b, c);
  int bits = 32;
  unsigned int range = 0xffffffff;
  unsigned int code = 0x3f914584;
  while (--bits) {
    range >>= 1;
    code -= range;
    printf("range=%x, code=%x\n", range, code);
    unsigned int t = 0 - ((unsigned int)code >> 31);
    code += range & t;
    printf("range=%x, code=%x, t=%x\n", range, code, t);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x100000,-0x8(%rbp)
xor    %eax,%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%esi
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x3f914584,-0x8(%rbp)
movl   $0xffffffff,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x3f914584,-0x8(%rbp)
movl   $0x3f914585,-0xc(%rbp)
mov    -0x8(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x20,-0x14(%rbp)
movl   $0xffffffff,-0x18(%rbp)
movl   $0x3f914584,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     1294 <main+0x184>
mov    -0x18(%rbp),%eax
shr    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%ecx
shr    $0x1f,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
and    -0x20(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1225 <main+0x115>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xee1(%rip),%rdi
mov    $0x100000,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
mov    $0x100000,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec9(%rip),%rdi
mov    $0xfff00000,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xebc(%rip),%rdi
mov    $0xfff00000,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeb1(%rip),%rdi
mov    $0xffffffff,%ebx
mov    $0xffffffff,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xea1(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe96(%rip),%rdi
mov    $0x3f914584,%ebp
mov    $0x3f914584,%esi
mov    $0xffffffff,%edx
mov    $0x3f914585,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe7e(%rip),%rdi
mov    $0x3f914584,%esi
mov    $0x3f914585,%edx
mov    $0x7f228b09,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xffffffe1,%r12d
lea    0xe65(%rip),%r14
lea    0xe71(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
shr    %ebx
sub    %ebx,%ebp
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebp,%ecx
sar    $0x1f,%ecx
mov    %ecx,%eax
and    %ebx,%eax
add    %eax,%ebp
mov    %r15,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
inc    %r12d
jne    11f0 <main+0xe0>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"a=%u\0A\00"
@.str.1 = [8 x i8] c"a=0x%x\0A\00"
@.str.2 = [6 x i8] c"b=%u\0A\00"
@.str.3 = [8 x i8] c"b=0x%x\0A\00"
@.str.4 = [8 x i8] c"1-2=%x\0A\00"
@.str.5 = [8 x i8] c"2-1=%x\0A\00"
@.str.6 = [10 x i8] c"%x-%x=%x\0A\00"
@.str.7 = [10 x i8] c"%x+%x=%x\0A\00"
@.str.8 = [19 x i8] c"range=%x, code=%x\0A\00"
@.str.9 = [25 x i8] c"range=%x, code=%x, t=%x\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 1048576, i32* %2
%9 = load i32, i32* %2
%10 = sub i32 0, %9
store i32 %10, i32* %3
%11 = load i32, i32* %2
%12 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %2
%14 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %3
%16 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %3
%18 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %17)
store i32 1, i32* %2
store i32 2, i32* %3
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = sub i32 %19, %20
store i32 %21, i32* %4
%22 = load i32, i32* %4
%23 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %3
%25 = load i32, i32* %2
%26 = sub i32 %24, %25
store i32 %26, i32* %4
%27 = load i32, i32* %4
%28 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %27)
store i32 1066485124, i32* %2
store i32 -1, i32* %3
%29 = load i32, i32* %2
%30 = load i32, i32* %3
%31 = sub i32 %29, %30
store i32 %31, i32* %4
%32 = load i32, i32* %2
%33 = load i32, i32* %3
%34 = load i32, i32* %4
%35 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 %32, i32 %33, i32 %34)
store i32 1066485124, i32* %2
store i32 1066485125, i32* %3
%36 = load i32, i32* %2
%37 = load i32, i32* %3
%38 = add i32 %36, %37
store i32 %38, i32* %4
%39 = load i32, i32* %2
%40 = load i32, i32* %3
%41 = load i32, i32* %4
%42 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 %39, i32 %40, i32 %41)
store i32 32, i32* %5
store i32 -1, i32* %6
store i32 1066485124, i32* %7
br label %43
43: ; preds = %47, %0
%44 = load i32, i32* %5
%45 = add nsw i32 %44, -1
store i32 %45, i32* %5
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %68
47: ; preds = %43
%48 = load i32, i32* %6
%49 = lshr i32 %48, 1
store i32 %49, i32* %6
%50 = load i32, i32* %6
%51 = load i32, i32* %7
%52 = sub i32 %51, %50
store i32 %52, i32* %7
%53 = load i32, i32* %6
%54 = load i32, i32* %7
%55 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i32 %53, i32 %54)
%56 = load i32, i32* %7
%57 = lshr i32 %56, 31
%58 = sub i32 0, %57
store i32 %58, i32* %8
%59 = load i32, i32* %6
%60 = load i32, i32* %8
%61 = and i32 %59, %60
%62 = load i32, i32* %7
%63 = add i32 %62, %61
store i32 %63, i32* %7
%64 = load i32, i32* %6
%65 = load i32, i32* %7
%66 = load i32, i32* %8
%67 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0), i32 %64, i32 %65, i32 %66)
br label %43
68: ; preds = %43
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"a=%u\0A\00"
@.str.1 = [8 x i8] c"a=0x%x\0A\00"
@.str.2 = [6 x i8] c"b=%u\0A\00"
@.str.3 = [8 x i8] c"b=0x%x\0A\00"
@.str.4 = [8 x i8] c"1-2=%x\0A\00"
@.str.5 = [8 x i8] c"2-1=%x\0A\00"
@.str.6 = [10 x i8] c"%x-%x=%x\0A\00"
@.str.7 = [10 x i8] c"%x+%x=%x\0A\00"
@.str.8 = [19 x i8] c"range=%x, code=%x\0A\00"
@.str.9 = [25 x i8] c"range=%x, code=%x, t=%x\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 1048576)
%2 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 1048576)
%3 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 -1048576)
%4 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 -1048576)
%5 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 -1)
%6 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 1)
%7 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 1066485124, i32 -1, i32 1066485125)
%8 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 1066485124, i32 1066485125, i32 2132970249)
br label %9
9: ; preds = %0, %9
%10 = phi i32 [ 31, %0 ], [ %20, %9 ]
%11 = phi i32 [ 1066485124, %0 ], [ %18, %9 ]
%12 = phi i32 [ -1, %0 ], [ %13, %9 ]
%13 = lshr i32 %12, 1
%14 = sub i32 %11, %13
%15 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0), i32 %13, i32 %14)
%16 = ashr i32 %14, 31
%17 = and i32 %16, %13
%18 = add i32 %17, %14
%19 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0), i32 %13, i32 %18, i32 %16)
%20 = add nsw i32 %10, -1
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %9
22: ; preds = %9
ret i32 0
}