#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 *, int, ...);
void max_size() {
  int i, j, k, k_b, perem;
  unsigned int step;
  short sh, end;
  k = 0;
  i = 0;
  j = 0;
  sh = 0;
  i = 0;
  k = 10;
  k_b = 0;
  while (k > 0) {
    k_b = k;
    k = k * 10;
    ++i;
    printf("at step %d k=%d;\n", i, k);
  }
  printf("after first searching cycle k_b=%d;\n", k_b);
  k = k_b;
  k_b = 0;
  end = 0;
  i = 0;
  step = 0;
  while (step >= 0) {
    step = k / 10;
    printf("step=%d;\n", step);
    ++i;
    if (i == 10)
      getchar();
    j = 0;
    while (k > 0) {
      k_b = k;
      printf("k+step=%d;k=%d\n", k + step, k);
      perem = k + step;
      while (perem < 0) {
        step = step / 10;
        perem = k + step;
        printf("inside check step=%d;\n", step);
      }
      ++j;
      if (j == 20)
        getchar();
      printf("step after check=%d;\n", step);
      k = k + step;
      printf("in the end of cycle k=%d;k_b=%d\n", k, k_b);
    }
    k = k_b;
    k_b = 0;
    printf("after removing k=%d;k_b=%d\n", k, k_b);
  }
  printf("in the end k=%d;\n", k);
}


x86 assembly (clang, -O0):
<max_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movw   $0x0,-0x1a(%rbp)
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    1191 <max_size+0x71>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
imul   $0xa,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1158 <max_size+0x38>
mov    -0x10(%rbp),%esi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movw   $0x0,-0x1c(%rbp)
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jb     12e8 <max_size+0x1c8>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
cmpl   $0xa,-0x4(%rbp)
jne    1206 <max_size+0xe6>
mov    $0x0,%al
call   1040 <getchar@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    12c2 <max_size+0x1a2>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%esi
add    -0x18(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1275 <max_size+0x155>
mov    -0x18(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%esi
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    123d <max_size+0x11d>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x14,-0x8(%rbp)
jne    128f <max_size+0x16f>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    -0x18(%rbp),%esi
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    120d <max_size+0xed>
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xdb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c3 <max_size+0xa3>
mov    -0xc(%rbp),%esi
lea    0xdbf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<max_size>:
push   %rbp
push   %r14
push   %rbx
mov    $0xa,%ebx
mov    $0x1,%ebp
lea    0xedb(%rip),%r14
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+0x20>

LLVM IR (-O0):
@.str = [18 x i8] c"at step %d k=%d;\0A\00"
@.str.1 = [37 x i8] c"after first searching cycle k_b=%d;\0A\00"
@.str.2 = [10 x i8] c"step=%d;\0A\00"
@.str.3 = [16 x i8] c"k+step=%d;k=%d\0A\00"
@.str.4 = [23 x i8] c"inside check step=%d;\0A\00"
@.str.5 = [22 x i8] c"step after check=%d;\0A\00"
@.str.6 = [33 x i8] c"in the end of cycle k=%d;k_b=%d\0A\00"
@.str.7 = [28 x i8] c"after removing k=%d;k_b=%d\0A\00"
@.str.8 = [18 x i8] c"in the end k=%d;\0A\00"
define void @max_size() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i16
%8 = alloca i16
store i32 0, i32* %3
store i32 0, i32* %1
store i32 0, i32* %2
store i16 0, i16* %7
store i32 0, i32* %1
store i32 10, i32* %3
store i32 0, i32* %4
br label %9
9: ; preds = %12, %0
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %21
12: ; preds = %9
%13 = load i32, i32* %3
store i32 %13, i32* %4
%14 = load i32, i32* %3
%15 = mul nsw i32 %14, 10
store i32 %15, i32* %3
%16 = load i32, i32* %1
%17 = add nsw i32 %16, 1
store i32 %17, i32* %1
%18 = load i32, i32* %1
%19 = load i32, i32* %3
%20 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 %18, i32 %19)
br label %9
21: ; preds = %9
%22 = load i32, i32* %4
%23 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %4
store i32 %24, i32* %3
store i32 0, i32* %4
store i16 0, i16* %8
store i32 0, i32* %1
store i32 0, i32* %6
br label %25
25: ; preds = %80, %21
%26 = load i32, i32* %6
%27 = icmp uge i32 %26, 0
br i1 %27, label %28, label %85
28: ; preds = %25
%29 = load i32, i32* %3
%30 = sdiv i32 %29, 10
store i32 %30, i32* %6
%31 = load i32, i32* %6
%32 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %1
%34 = add nsw i32 %33, 1
store i32 %34, i32* %1
%35 = load i32, i32* %1
%36 = icmp eq i32 %35, 10
br i1 %36, label %37, label %39
37: ; preds = %28
%38 = call i32 (...) @getchar()
br label %39
39: ; preds = %37, %28
store i32 0, i32* %2
br label %40
40: ; preds = %71, %39
%41 = load i32, i32* %3
%42 = icmp sgt i32 %41, 0
br i1 %42, label %43, label %80
43: ; preds = %40
%44 = load i32, i32* %3
store i32 %44, i32* %4
%45 = load i32, i32* %3
%46 = load i32, i32* %6
%47 = add i32 %45, %46
%48 = load i32, i32* %3
%49 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32 %47, i32 %48)
%50 = load i32, i32* %3
%51 = load i32, i32* %6
%52 = add i32 %50, %51
store i32 %52, i32* %5
br label %53
53: ; preds = %56, %43
%54 = load i32, i32* %5
%55 = icmp slt i32 %54, 0
br i1 %55, label %56, label %64
56: ; preds = %53
%57 = load i32, i32* %6
%58 = udiv i32 %57, 10
store i32 %58, i32* %6
%59 = load i32, i32* %3
%60 = load i32, i32* %6
%61 = add i32 %59, %60
store i32 %61, i32* %5
%62 = load i32, i32* %6
%63 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %62)
br label %53
64: ; preds = %53
%65 = load i32, i32* %2
%66 = add nsw i32 %65, 1
store i32 %66, i32* %2
%67 = load i32, i32* %2
%68 = icmp eq i32 %67, 20
br i1 %68, label %69, label %71
69: ; preds = %64
%70 = call i32 (...) @getchar()
br label %71
71: ; preds = %69, %64
%72 = load i32, i32* %6
%73 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i32 %72)
%74 = load i32, i32* %3
%75 = load i32, i32* %6
%76 = add i32 %74, %75
store i32 %76, i32* %3
%77 = load i32, i32* %3
%78 = load i32, i32* %4
%79 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 %77, i32 %78)
br label %40
80: ; preds = %40
%81 = load i32, i32* %4
store i32 %81, i32* %3
store i32 0, i32* %4
%82 = load i32, i32* %3
%83 = load i32, i32* %4
%84 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i32 %82, i32 %83)
br label %25
85: ; preds = %25
%86 = load i32, i32* %3
%87 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), i32 %86)
ret void
}

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