#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*/ sprintf(char *, char *, int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int change(int num) {
  char temp[15];
  int newnum, count, count2;
  sprintf(temp, "%d", num);
  char temp2[15];
  for (count = 0, count2 = 0; temp[count] != '\0'; count++) {
    if (temp[count] == '0')
      continue;
    else
      temp2[count2++] = temp[count];
  }
  temp2[count2] = '\0';
  sscanf(temp2, "%d", &newnum);
  return newnum;
}


x86 assembly (clang, -O0):
<change>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x13(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xec7(%rip),%rsi
call   1040 <sprintf@plt>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movslq -0x1c(%rbp),%rax
movsbl -0x13(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11a1 <change+0x81>
movslq -0x1c(%rbp),%rax
movsbl -0x13(%rbp,%rax,1),%eax
cmp    $0x30,%eax
jne    1175 <change+0x55>
jmp    1193 <change+0x73>
movslq -0x1c(%rbp),%rax
mov    -0x13(%rbp,%rax,1),%cl
mov    -0x20(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x20(%rbp)
cltq
mov    %cl,-0x2f(%rbp,%rax,1)
jmp    1193 <change+0x73>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114c <change+0x2c>
movslq -0x20(%rbp),%rax
movb   $0x0,-0x2f(%rbp,%rax,1)
lea    -0x2f(%rbp),%rdi
lea    0xe4b(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1030 <sscanf@plt>
mov    -0x18(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<change>:
push   %rbx
sub    $0x30,%rsp
mov    %edi,%edx
lea    0xed2(%rip),%rsi
lea    0x21(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <sprintf@plt>
xor    %eax,%eax
jmp    1144 <change+0x24>
nop
add    $0x1,%rbx
movzbl (%rbx),%ecx
cmp    $0x30,%cl
je     1140 <change+0x20>
movslq %eax,%rdx
test   %cl,%cl
je     115c <change+0x3c>
lea    0x1(%rdx),%eax
mov    %cl,0x12(%rsp,%rdx,1)
jmp    1140 <change+0x20>
movb   $0x0,0x12(%rsp,%rdx,1)
lea    0xe98(%rip),%rsi
lea    0x12(%rsp),%rdi
lea    0xc(%rsp),%rdx
call   1030 <sscanf@plt>
mov    0xc(%rsp),%eax
add    $0x30,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @change(i32 %0) {
%2 = alloca [15 x i8]
%3 = alloca i32
%4 = alloca [15 x i8]
%5 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%6 = bitcast i32* %3 to i8*
%7 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %0)
%8 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 0
br label %9
9: ; preds = %18, %1
%10 = phi i64 [ %20, %18 ], [ 0, %1 ]
%11 = phi i32 [ %19, %18 ], [ 0, %1 ]
%12 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 %10
%13 = load i8, i8* %12
switch i8 %13, label %14 [
i8 0, label %21
i8 48, label %18
]
14: ; preds = %9
%15 = add nsw i32 %11, 1
%16 = sext i32 %11 to i64
%17 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 %16
store i8 %13, i8* %17
br label %18
18: ; preds = %9, %14
%19 = phi i32 [ %15, %14 ], [ %11, %9 ]
%20 = add nuw i64 %10, 1
br label %9
21: ; preds = %9
%22 = sext i32 %11 to i64
%23 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 %22
store i8 0, i8* %23
%24 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%25 = load i32, i32* %3
ret i32 %25
}