#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, ...);
void print_absolute(int addr, int val) {
  if (val >= 10000)
    printf("%03d: 9999 Error: Illegal opcode; treated as 9999", addr);
  else if (val % 1000 > 512)
    printf("%03d: %04d Error: Absolute address exceeds machine size; zero used",
           addr, (((val) / 1000) * 1000));
  else
    printf("%03d: %04d", addr, val);
}


x86 assembly (clang, -O0):
<print_absolute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x2710,-0x8(%rbp)
jl     1141 <print_absolute+0x31>
mov    -0x4(%rbp),%esi
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1198 <print_absolute+0x88>
mov    -0x8(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cmp    $0x200,%edx
jle    117f <print_absolute+0x6f>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
imul   $0x3e8,%eax,%edx
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1193 <print_absolute+0x83>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xee9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1198 <print_absolute+0x88>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_absolute>:
mov    %esi,%edx
mov    %edi,%esi
cmp    $0x2710,%edx
jl     112a <print_absolute+0x1a>
lea    0xedd(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
movslq %edx,%rax
imul   $0x10624dd3,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
imul   $0x3e8,%eax,%ecx
mov    %edx,%eax
sub    %ecx,%eax
cmp    $0x201,%eax
jl     1162 <print_absolute+0x52>
sub    %eax,%edx
lea    0xed7(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>
lea    0xf0c(%rip),%rdi
xor    %eax,%eax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [50 x i8] c"%03d: 9999 Error: Illegal opcode; treated as 9999\00"
@.str.1 = [67 x i8] c"%03d: %04d Error: Absolute address exceeds machine size; zero used\00"
@.str.2 = [11 x i8] c"%03d: %04d\00"
define void @print_absolute(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp sge i32 %5, 10000
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = load i32, i32* %3
%9 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %25
10: ; preds = %2
%11 = load i32, i32* %4
%12 = srem i32 %11, 1000
%13 = icmp sgt i32 %12, 512
br i1 %13, label %14, label %20
14: ; preds = %10
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = sdiv i32 %16, 1000
%18 = mul nsw i32 %17, 1000
%19 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %18)
br label %24
20: ; preds = %10
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %21, i32 %22)
br label %24
24: ; preds = %20, %14
br label %25
25: ; preds = %24, %7
ret void
}

LLVM IR (-O2):
@.str = [50 x i8] c"%03d: 9999 Error: Illegal opcode; treated as 9999\00"
@.str.1 = [67 x i8] c"%03d: %04d Error: Absolute address exceeds machine size; zero used\00"
@.str.2 = [11 x i8] c"%03d: %04d\00"
define void @print_absolute(i32 %0, i32 %1) {
%3 = icmp sgt i32 %1, 9999
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %14
6: ; preds = %2
%7 = srem i32 %1, 1000
%8 = icmp sgt i32 %7, 512
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = sub i32 %1, %7
%11 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0), i32 %0, i32 %10)
br label %14
12: ; preds = %6
%13 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %0, i32 %1)
br label %14
14: ; preds = %9, %12, %4
ret void
}