new_int(name, value) char *name;
int *value;
{
  char svalue[200];
  sprintf(svalue, "%d", *value);
  if (new_string(name, svalue) == 0 || strlen(svalue) == 0)
    return (-1);
  *value = atoi(svalue);
  return (0);
}


x86 assembly (clang, -O0):
<new_int>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0xe0(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xe99(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    -0x10(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
mov    $0x0,%al
call   1040 <new_string@plt>
cmp    $0x0,%eax
je     119f <new_int+0x5f>
lea    -0xe0(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jne    11ab <new_int+0x6b>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c8 <new_int+0x88>
lea    -0xe0(%rbp),%rdi
mov    $0x0,%al
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<new_int>:
push   %rbp
push   %r14
push   %rbx
sub    $0xd0,%rsp
mov    %rsi,%r14
mov    %rdi,%rbp
mov    (%rsi),%edx
lea    0xeb6(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <sprintf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <new_string@plt>
mov    $0xffffffff,%ebp
test   %eax,%eax
je     1182 <new_int+0x52>
cmpb   $0x0,(%rsp)
je     1182 <new_int+0x52>
xor    %ebp,%ebp
mov    %rsp,%rdi
xor    %eax,%eax
call   1040 <atoi@plt>
mov    %eax,(%r14)
mov    %ebp,%eax
add    $0xd0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
define i32 @new_int(i8* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca [200 x i8]
store i8* %0, i8** %4
store i32* %1, i32** %5
%7 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%8 = load i32*, i32** %5
%9 = load i32, i32* %8
%10 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i8*, i8** %4
%12 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%13 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @new_string to i32 (i8*, i8*, ...)*)(i8* %11, i8* %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %2
%16 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%17 = call i64 @strlen(i8* %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %15, %2
store i32 -1, i32* %3
br label %24
20: ; preds = %15
%21 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%22 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %21)
%23 = load i32*, i32** %5
store i32 %22, i32* %23
store i32 0, i32* %3
br label %24
24: ; preds = %20, %19
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define i32 @new_int(i8* %0, i32* nocapture %1) {
%3 = alloca [200 x i8]
%4 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* %1
%6 = call i32 (i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @new_string to i32 (i8*, i8*, ...)*)(i8* %0, i8* %4)
%8 = icmp eq i32 %7, 0
%9 = load i8, i8* %4
%10 = icmp eq i8 %9, 0
%11 = select i1 %8, i1 true, i1 %10
br i1 %11, label %14, label %12
12: ; preds = %2
%13 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %4)
store i32 %13, i32* %1
br label %14
14: ; preds = %2, %12
%15 = phi i32 [ 0, %12 ], [ -1, %2 ]
ret i32 %15
}