#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 *, char *);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  int increment(char *a, int, int);
  int i;
  char a[100];
  scanf("%s", a);
  int len = strlen(a);
  if (a[0] = '9') {
    for (i = len; i > 0; i--)
      a[i + 1] = a[i];
    a[0] = '0';
    len++;
  }
  increment(a, len - 1, 0);
  printf("%s", a);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rsi
lea    0xea3(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x74(%rbp)
movb   $0x39,-0x70(%rbp)
mov    $0x1,%al
test   $0x1,%al
jne    1181 <main+0x41>
jmp    11c0 <main+0x80>
mov    -0x74(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    11b3 <main+0x73>
movslq -0x8(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%cl
mov    -0x8(%rbp),%eax
add    $0x1,%eax
cltq
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1187 <main+0x47>
movb   $0x30,-0x70(%rbp)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x74(%rbp),%esi
sub    $0x1,%esi
xor    %edx,%edx
call   1030 <increment@plt>
lea    -0x70(%rbp),%rsi
lea    0xe24(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
lea    0xeb4(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
movb   $0x39,(%rsp)
test   %eax,%eax
jle    11b2 <main+0x72>
mov    %eax,%ecx
lea    -0x1(%rcx),%rdx
mov    %rcx,%rsi
and    $0x3,%rsi
je     1192 <main+0x52>
cs nopw 0x0(%rax,%rax,1)
movzbl (%rsp,%rcx,1),%ebx
mov    %bl,0x1(%rsp,%rcx,1)
add    $0xffffffffffffffff,%rcx
add    $0xffffffffffffffff,%rsi
jne    1180 <main+0x40>
cmp    $0x3,%rdx
jb     11b2 <main+0x72>
add    $0x1,%rcx
nopl   0x0(%rax)
mov    -0x4(%rsp,%rcx,1),%edx
mov    %edx,-0x3(%rsp,%rcx,1)
add    $0xfffffffffffffffc,%rcx
cmp    $0x1,%rcx
ja     11a0 <main+0x60>
movb   $0x30,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %edx,%edx
call   1030 <increment@plt>
lea    0xe34(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %4
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
store i8 57, i8* %9
br i1 true, label %10, label %31
10: ; preds = %0
%11 = load i32, i32* %4
store i32 %11, i32* %2
br label %12
12: ; preds = %24, %10
%13 = load i32, i32* %2
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %27
15: ; preds = %12
%16 = load i32, i32* %2
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %22
store i8 %19, i8* %23
br label %24
24: ; preds = %15
%25 = load i32, i32* %2
%26 = add nsw i32 %25, -1
store i32 %26, i32* %2
br label %12
27: ; preds = %12
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
store i8 48, i8* %28
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %31
31: ; preds = %27, %0
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%33 = load i32, i32* %4
%34 = sub nsw i32 %33, 1
%35 = call i32 @increment(i8* %32, i32 %34, i32 0)
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%37 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %36)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = call i32 @strlen(i8* %2)
store i8 57, i8* %2
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %44
6: ; preds = %0
%7 = zext i32 %4 to i64
%8 = add nsw i64 %7, -1
%9 = and i64 %7, 3
%10 = icmp eq i64 %9, 0
br i1 %10, label %21, label %11
11: ; preds = %6, %11
%12 = phi i64 [ %18, %11 ], [ %7, %6 ]
%13 = phi i64 [ %19, %11 ], [ 0, %6 ]
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %12
%15 = load i8, i8* %14
%16 = add nuw nsw i64 %12, 1
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %16
store i8 %15, i8* %17
%18 = add nsw i64 %12, -1
%19 = add i64 %13, 1
%20 = icmp eq i64 %19, %9
br i1 %20, label %21, label %11
21: ; preds = %11, %6
%22 = phi i64 [ %7, %6 ], [ %18, %11 ]
%23 = icmp ult i64 %8, 3
br i1 %23, label %44, label %24
24: ; preds = %21, %24
%25 = phi i64 [ %42, %24 ], [ %22, %21 ]
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = add nuw nsw i64 %25, 1
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %28
store i8 %27, i8* %29
%30 = add nsw i64 %25, -1
%31 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %25
store i8 %32, i8* %33
%34 = add nsw i64 %25, -2
%35 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %30
store i8 %36, i8* %37
%38 = add nsw i64 %25, -3
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %34
store i8 %40, i8* %41
%42 = add nsw i64 %25, -4
%43 = icmp ugt i64 %38, 1
br i1 %43, label %24, label %44
44: ; preds = %21, %24, %0
store i8 48, i8* %2
%45 = call i32 @increment(i8* %2, i32 %4, i32 0)
%46 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
ret i32 0
}