#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 atoi(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, int);
int main(int argc, char *argv[]) {
  char ta[4], tb[4];
  int i, j, k, bi, sc, sh;
  bi = 4096;
  sc = 2580;
  sh = 8;
  for (i = 0; i < 1000; i++) {
    sprintf(ta, "%03d", i);
    j = i;
    j = (i * 1073741 + 1048575) >> 20;
    j = j * 10;
    tb[0] = '0' + (j >> 10);
    j &= 1023;
    j = j * 10;
    tb[1] = '0' + (j >> 10);
    j &= 1023;
    j = j * 10;
    tb[2] = '0' + (j >> 10);
    j &= 1023;
    tb[3] = 0;
    printf("% d ", atoi(ta) - atoi(tb));
    if (i && !((i + 1) % 25))
      printf("\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1000,-0x28(%rbp)
movl   $0xa14,-0x2c(%rbp)
movl   $0x8,-0x30(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3e8,-0x1c(%rbp)
jge    1262 <main+0x132>
lea    -0x14(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0xe83(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
imul   $0x10624d,-0x1c(%rbp),%eax
add    $0xfffff,%eax
sar    $0x14,%eax
mov    %eax,-0x20(%rbp)
imul   $0xa,-0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
sar    $0xa,%eax
add    $0x30,%eax
mov    %al,-0x18(%rbp)
mov    -0x20(%rbp),%eax
and    $0x3ff,%eax
mov    %eax,-0x20(%rbp)
imul   $0xa,-0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
sar    $0xa,%eax
add    $0x30,%eax
mov    %al,-0x17(%rbp)
mov    -0x20(%rbp),%eax
and    $0x3ff,%eax
mov    %eax,-0x20(%rbp)
imul   $0xa,-0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
sar    $0xa,%eax
add    $0x30,%eax
mov    %al,-0x16(%rbp)
mov    -0x20(%rbp),%eax
and    $0x3ff,%eax
mov    %eax,-0x20(%rbp)
movb   $0x0,-0x15(%rbp)
lea    -0x14(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x34(%rbp)
lea    -0x18(%rbp),%rdi
call   1040 <atoi@plt>
mov    -0x34(%rbp),%esi
sub    %eax,%esi
lea    0xdec(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x1c(%rbp)
je     124f <main+0x11f>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    $0x19,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    124f <main+0x11f>
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1254 <main+0x124>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1162 <main+0x32>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeae(%rip),%rsi
lea    0x4(%rsp),%r13
mov    %r13,%rdi
xor    %edx,%edx
call   1060 <sprintf@plt>
movl   $0x303030,(%rsp)
mov    %r13,%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
mov    %rsp,%rdi
call   1050 <atoi@plt>
sub    %eax,%ebx
lea    0xe82(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebx
mov    $0x20624c,%r14d
mov    $0x2,%r15w
jmp    11ba <main+0x7a>
xchg   %ax,%ax
add    $0x1,%ebx
add    $0x10624d,%r14d
add    $0x1,%r15d
cmp    $0x3e8,%ebx
je     127a <main+0x13a>
movzwl %r15w,%eax
imul   $0x47af,%eax,%eax
shr    $0x10,%eax
mov    %r15d,%ecx
sub    %eax,%ecx
movzwl %cx,%ecx
shr    %ecx
add    %eax,%ecx
shr    $0x4,%ecx
lea    (%rcx,%rcx,4),%eax
lea    (%rax,%rax,4),%r12d
mov    %r13,%rdi
lea    0xe19(%rip),%rsi
mov    %ebx,%edx
call   1060 <sprintf@plt>
mov    %r14d,%eax
shr    $0x13,%eax
and    $0xfffffffe,%eax
lea    (%rax,%rax,4),%eax
mov    %eax,%ecx
shr    $0xa,%ecx
add    $0x30,%cl
mov    %cl,(%rsp)
and    $0x3fe,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    %eax,%ecx
shr    $0xa,%ecx
or     $0x30,%cl
mov    %cl,0x1(%rsp)
and    $0x3fc,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
shr    $0xa,%eax
or     $0x30,%al
mov    %al,0x2(%rsp)
movb   $0x0,0x3(%rsp)
mov    %r13,%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
mov    %rsp,%rdi
call   1050 <atoi@plt>
sub    %eax,%ebp
lea    0xdb7(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
neg    %r12d
lea    (%rbx,%r12,1),%eax
add    $0x2,%eax
cmp    $0x1,%ax
jne    11a0 <main+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11a0 <main+0x60>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%03d\00"
@.str.1 = [5 x i8] c"% d \00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4 x i8]
%7 = alloca [4 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 4096, i32* %11
store i32 2580, i32* %12
store i32 8, i32* %13
store i32 0, i32* %8
br label %14
14: ; preds = %70, %2
%15 = load i32, i32* %8
%16 = icmp slt i32 %15, 1000
br i1 %16, label %17, label %73
17: ; preds = %14
%18 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%19 = load i32, i32* %8
%20 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %8
store i32 %21, i32* %9
%22 = load i32, i32* %8
%23 = mul nsw i32 %22, 1073741
%24 = add nsw i32 %23, 1048575
%25 = ashr i32 %24, 20
store i32 %25, i32* %9
%26 = load i32, i32* %9
%27 = mul nsw i32 %26, 10
store i32 %27, i32* %9
%28 = load i32, i32* %9
%29 = ashr i32 %28, 10
%30 = add nsw i32 48, %29
%31 = trunc i32 %30 to i8
%32 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
store i8 %31, i8* %32
%33 = load i32, i32* %9
%34 = and i32 %33, 1023
store i32 %34, i32* %9
%35 = load i32, i32* %9
%36 = mul nsw i32 %35, 10
store i32 %36, i32* %9
%37 = load i32, i32* %9
%38 = ashr i32 %37, 10
%39 = add nsw i32 48, %38
%40 = trunc i32 %39 to i8
%41 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 1
store i8 %40, i8* %41
%42 = load i32, i32* %9
%43 = and i32 %42, 1023
store i32 %43, i32* %9
%44 = load i32, i32* %9
%45 = mul nsw i32 %44, 10
store i32 %45, i32* %9
%46 = load i32, i32* %9
%47 = ashr i32 %46, 10
%48 = add nsw i32 48, %47
%49 = trunc i32 %48 to i8
%50 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 2
store i8 %49, i8* %50
%51 = load i32, i32* %9
%52 = and i32 %51, 1023
store i32 %52, i32* %9
%53 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 3
store i8 0, i8* %53
%54 = getelementptr inbounds [4 x i8], [4 x i8]* %6, i64 0, i64 0
%55 = call i32 @atoi(i8* %54)
%56 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%57 = call i32 @atoi(i8* %56)
%58 = sub nsw i32 %55, %57
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %58)
%60 = load i32, i32* %8
%61 = icmp ne i32 %60, 0
br i1 %61, label %62, label %69
62: ; preds = %17
%63 = load i32, i32* %8
%64 = add nsw i32 %63, 1
%65 = srem i32 %64, 25
%66 = icmp ne i32 %65, 0
br i1 %66, label %69, label %67
67: ; preds = %62
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %69
69: ; preds = %67, %62, %17
br label %70
70: ; preds = %69
%71 = load i32, i32* %8
%72 = add nsw i32 %71, 1
store i32 %72, i32* %8
br label %14
73: ; preds = %14
%74 = load i32, i32* %3
ret i32 %74
}

LLVM IR (-O2):
@.str = [5 x i8] c"%03d\00"
@.str.1 = [5 x i8] c"% d \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [4 x i8]
%4 = alloca [4 x i8]
%5 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 1
%8 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 2
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 3
%10 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 0)
store i8 48, i8* %6
store i8 48, i8* %7
store i8 48, i8* %8
store i8 0, i8* %9
%11 = call i32 @atoi(i8* %5)
%12 = call i32 @atoi(i8* %6)
%13 = sub nsw i32 %11, %12
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %45, %2
%16 = phi i32 [ 1, %2 ], [ %46, %45 ]
%17 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = mul nuw nsw i32 %16, 1073741
%19 = add nuw nsw i32 %18, 1048575
%20 = lshr i32 %19, 20
%21 = mul nuw nsw i32 %20, 10
%22 = lshr i32 %21, 10
%23 = trunc i32 %22 to i8
%24 = add nuw nsw i8 %23, 48
store i8 %24, i8* %6
%25 = and i32 %21, 1022
%26 = mul nuw nsw i32 %25, 10
%27 = lshr i32 %26, 10
%28 = trunc i32 %27 to i8
%29 = or i8 %28, 48
store i8 %29, i8* %7
%30 = and i32 %26, 1020
%31 = mul nuw nsw i32 %30, 10
%32 = lshr i32 %31, 10
%33 = trunc i32 %32 to i8
%34 = or i8 %33, 48
store i8 %34, i8* %8
store i8 0, i8* %9
%35 = call i32 @atoi(i8* %5)
%36 = call i32 @atoi(i8* %6)
%37 = sub nsw i32 %35, %36
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %37)
%39 = trunc i32 %16 to i16
%40 = add nuw nsw i16 %39, 1
%41 = urem i16 %40, 25
%42 = icmp eq i16 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %15
%44 = tail call i32 @putchar(i32 10)
br label %45
45: ; preds = %15, %43
%46 = add nuw nsw i32 %16, 1
%47 = icmp eq i32 %46, 1000
br i1 %47, label %48, label %15
48: ; preds = %45
ret i32 0
}