#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*/ getchar();
int /*<<< orphan*/ printf(char *, unsigned int, ...);
void max_size_uint() {
  int i, j;
  unsigned int step, d, d_p;
  i = j = 0;
  step = d = d_p = 0;
  d = 1;
  while (d > 0) {
    ++i;
    d_p = d;
    d = d * 10;
    printf("at step %2i d=%11d;d_p=%11d;cycle 1\n", i, d, d_p);
  }
  d = d_p;
  printf("backup) d=%11d;\n", d);
  step = d;
  while (step > 1) {
    step = step / 10;
    i = 0;
    while (d > 0) {
      d_p = d;
      d = d + step;
      ++i;
      if (i == 100)
        getchar();
      printf("at step %2d d=%11d;\n", i, d);
    }
    d = d_p;
    printf("backup2)) step=%2d;d=%11d;\n", step, d);
  }
}


x86 assembly (clang, -O0):
<max_size_uint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jbe    118e <max_size_uint+0x6e>
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
mov    -0x14(%rbp),%ecx
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1152 <max_size_uint+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)
jbe    1236 <max_size_uint+0x116>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0x0,-0x10(%rbp)
jbe    1217 <max_size_uint+0xf7>
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)
cmpl   $0x64,-0x4(%rbp)
jne    11fe <max_size_uint+0xde>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11cb <max_size_uint+0xab>
mov    -0x14(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ab <max_size_uint+0x8b>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<max_size_uint>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x1,%ebx
lea    0xec9(%rip),%r14
mov    $0x1,%ecx
nopl   0x0(%rax)
lea    (%rcx,%rcx,1),%eax
lea    (%rax,%rax,4),%ebp
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%ebx
mov    %ebp,%ecx
cmp    $0x21,%ebx
jne    1140 <max_size_uint+0x20>
lea    0xec0(%rip),%rdi
mov    $0x80000000,%ebp
mov    $0x80000000,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeb9(%rip),%r15
mov    $0x80000000,%r14d
jmp    11b6 <max_size_uint+0x96>
cs nopw 0x0(%rax,%rax,1)
nop
add    %r12d,%r13d
neg    %r13d
lea    0xeae(%rip),%rdi
mov    %r12d,%esi
mov    %r13d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13d,%ebp
cmp    $0x13,%r14d
mov    %r12d,%r14d
jbe    1207 <max_size_uint+0xe7>
mov    %r14d,%r12d
mov    $0xcccccccd,%eax
imul   %rax,%r12
shr    $0x23,%r12
mov    $0x0,%r13d
test   %ebp,%ebp
je     1196 <max_size_uint+0x76>
mov    %ebp,%r13d
neg    %r13d
add    %r12d,%ebp
mov    $0x1,%ebx
jmp    11f9 <max_size_uint+0xd9>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
add    %r12d,%ebp
add    $0x1,%ebx
sub    %r12d,%r13d
je     1190 <max_size_uint+0x70>
cmp    $0x64,%ebx
jne    11e0 <max_size_uint+0xc0>
xor    %eax,%eax
call   1040 <getchar@plt>
jmp    11e0 <max_size_uint+0xc0>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"at step %2i d=%11d;d_p=%11d;cycle 1\0A\00"
@.str.1 = [17 x i8] c"backup) d=%11d;\0A\00"
@.str.2 = [21 x i8] c"at step %2d d=%11d;\0A\00"
@.str.3 = [28 x i8] c"backup2)) step=%2d;d=%11d;\0A\00"
define void @max_size_uint() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %2
store i32 0, i32* %1
store i32 0, i32* %5
store i32 0, i32* %4
store i32 0, i32* %3
store i32 1, i32* %4
br label %6
6: ; preds = %9, %0
%7 = load i32, i32* %4
%8 = icmp ugt i32 %7, 0
br i1 %8, label %9, label %19
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 i32 %13, 10
store i32 %14, i32* %4
%15 = load i32, i32* %1
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16, i32 %17)
br label %6
19: ; preds = %6
%20 = load i32, i32* %5
store i32 %20, i32* %4
%21 = load i32, i32* %4
%22 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %4
store i32 %23, i32* %3
br label %24
24: ; preds = %48, %19
%25 = load i32, i32* %3
%26 = icmp ugt i32 %25, 1
br i1 %26, label %27, label %53
27: ; preds = %24
%28 = load i32, i32* %3
%29 = udiv i32 %28, 10
store i32 %29, i32* %3
store i32 0, i32* %1
br label %30
30: ; preds = %44, %27
%31 = load i32, i32* %4
%32 = icmp ugt i32 %31, 0
br i1 %32, label %33, label %48
33: ; preds = %30
%34 = load i32, i32* %4
store i32 %34, i32* %5
%35 = load i32, i32* %4
%36 = load i32, i32* %3
%37 = add i32 %35, %36
store i32 %37, i32* %4
%38 = load i32, i32* %1
%39 = add nsw i32 %38, 1
store i32 %39, i32* %1
%40 = load i32, i32* %1
%41 = icmp eq i32 %40, 100
br i1 %41, label %42, label %44
42: ; preds = %33
%43 = call i32 (...) @getchar()
br label %44
44: ; preds = %42, %33
%45 = load i32, i32* %1
%46 = load i32, i32* %4
%47 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %45, i32 %46)
br label %30
48: ; preds = %30
%49 = load i32, i32* %5
store i32 %49, i32* %4
%50 = load i32, i32* %3
%51 = load i32, i32* %4
%52 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %50, i32 %51)
br label %24
53: ; preds = %24
ret void
}

LLVM IR (-O2):
@.str = [37 x i8] c"at step %2i d=%11d;d_p=%11d;cycle 1\0A\00"
@.str.1 = [17 x i8] c"backup) d=%11d;\0A\00"
@.str.2 = [21 x i8] c"at step %2d d=%11d;\0A\00"
@.str.3 = [28 x i8] c"backup2)) step=%2d;d=%11d;\0A\00"
define void @max_size_uint() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 1, %0 ], [ %5, %1 ]
%3 = phi i32 [ 0, %0 ], [ %4, %1 ]
%4 = add nuw nsw i32 %3, 1
%5 = mul i32 %2, 10
%6 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %4, i32 %5, i32 %2)
%7 = icmp eq i32 %4, 32
br i1 %7, label %8, label %1
8: ; preds = %1
%9 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 -2147483648)
br label %10
10: ; preds = %8, %26
%11 = phi i32 [ %27, %26 ], [ -2147483648, %8 ]
%12 = phi i32 [ %13, %26 ], [ -2147483648, %8 ]
%13 = udiv i32 %12, 10
%14 = icmp eq i32 %11, 0
br i1 %14, label %26, label %15
15: ; preds = %10, %23
%16 = phi i32 [ %18, %23 ], [ %11, %10 ]
%17 = phi i32 [ %19, %23 ], [ 0, %10 ]
%18 = add i32 %16, %13
%19 = add nuw nsw i32 %17, 1
%20 = icmp eq i32 %19, 100
br i1 %20, label %21, label %23
21: ; preds = %15
%22 = tail call i32 (...) @getchar()
br label %23
23: ; preds = %21, %15
%24 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %19, i32 %18)
%25 = icmp eq i32 %18, 0
br i1 %25, label %26, label %15
26: ; preds = %23, %10
%27 = phi i32 [ 0, %10 ], [ %16, %23 ]
%28 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %13, i32 %27)
%29 = icmp ugt i32 %12, 19
br i1 %29, label %10, label %30
30: ; preds = %26
ret void
}