#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 max_size_int() {
  int i, j, step, d, d_p;
  i = j = step = d = d_p = 0;
  d = 1;
  while (d > 0) {
    ++i;
    d_p = d;
    d = d * 10;
    printf("at step %i d=%d;\n", i, d);
  }
  d = d_p;
  printf("backup) d=%d;\n", d);
  step = d;
  while (step > 1) {
    step = step / 10;
    i = 0;
    while (d > 0) {
      d_p = d;
      d = d + step;
      ++i;
      printf("at step %d d=%d;\n", i, d);
    }
    d = d_p;
    printf("backup2)) step=%d;d=%d;\n", step, d);
  }
}


x86 assembly (clang, -O0):
<max_size_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    117b <max_size_int+0x6b>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
imul   $0xa,-0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1142 <max_size_int+0x32>
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jle    1211 <max_size_int+0x101>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    11f2 <max_size_int+0xe2>
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b7 <max_size_int+0xa7>
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1198 <max_size_int+0x88>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<max_size_int>:
push   %rbp
push   %r14
push   %rbx
mov    $0x1,%ebp
lea    0xee0(%rip),%r14
mov    $0x1,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%ebx
mov    %r14,%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%ebp
jmp    1130 <max_size_int+0x20>

LLVM IR (-O0):
@.str = [18 x i8] c"at step %i d=%d;\0A\00"
@.str.1 = [15 x i8] c"backup) d=%d;\0A\00"
@.str.2 = [18 x i8] c"at step %d d=%d;\0A\00"
@.str.3 = [25 x i8] c"backup2)) step=%d;d=%d;\0A\00"
define void @max_size_int() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %5
store i32 0, i32* %4
store i32 0, i32* %3
store i32 0, i32* %2
store i32 0, i32* %1
store i32 1, i32* %4
br label %6
6: ; preds = %9, %0
%7 = load i32, i32* %4
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %18
9: ; preds = %6
%10 = load i32, i32* %1
%11 = add nsw i32 %10, 1
store i32 %11, i32* %1
%12 = load i32, i32* %4
store i32 %12, i32* %5
%13 = load i32, i32* %4
%14 = mul nsw i32 %13, 10
store i32 %14, i32* %4
%15 = load i32, i32* %1
%16 = load i32, i32* %4
%17 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16)
br label %6
18: ; preds = %6
%19 = load i32, i32* %5
store i32 %19, i32* %4
%20 = load i32, i32* %4
%21 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %4
store i32 %22, i32* %3
br label %23
23: ; preds = %42, %18
%24 = load i32, i32* %3
%25 = icmp sgt i32 %24, 1
br i1 %25, label %26, label %47
26: ; preds = %23
%27 = load i32, i32* %3
%28 = sdiv i32 %27, 10
store i32 %28, i32* %3
store i32 0, i32* %1
br label %29
29: ; preds = %32, %26
%30 = load i32, i32* %4
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %42
32: ; preds = %29
%33 = load i32, i32* %4
store i32 %33, i32* %5
%34 = load i32, i32* %4
%35 = load i32, i32* %3
%36 = add nsw i32 %34, %35
store i32 %36, i32* %4
%37 = load i32, i32* %1
%38 = add nsw i32 %37, 1
store i32 %38, i32* %1
%39 = load i32, i32* %1
%40 = load i32, i32* %4
%41 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %39, i32 %40)
br label %29
42: ; preds = %29
%43 = load i32, i32* %5
store i32 %43, i32* %4
%44 = load i32, i32* %3
%45 = load i32, i32* %4
%46 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %44, i32 %45)
br label %23
47: ; preds = %23
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"at step %i d=%d;\0A\00"
define void @max_size_int() {
br label %1
1: ; preds = %1, %0
%2 = phi i32 [ 0, %0 ], [ %4, %1 ]
%3 = phi i32 [ 1, %0 ], [ %5, %1 ]
%4 = add nuw nsw i32 %2, 1
%5 = mul nuw nsw i32 %3, 10
%6 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %5)
br label %1
}