#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*/ scanf(char *, char *);
scalar_t__ strcmp(char *, char *);
long strtol(char *, int /*<<< orphan*/ *, int);
int scan2int() {
  char sss[200];
  long int ii = 0;
  scanf("%s", sss);
  ii = strtol(sss, NULL, 10);
  if ((ii == 0) && (strcmp(sss, "0") != 0))
    ii = -1;
  return ((int)ii);
}


x86 assembly (clang, -O0):
<scan2int>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movq   $0x0,-0xd8(%rbp)
lea    -0xd0(%rbp),%rsi
lea    0xeac(%rip),%rdi
call   1050 <scanf@plt>
lea    -0xd0(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
mov    %rax,-0xd8(%rbp)
cmpq   $0x0,-0xd8(%rbp)
jne    11ab <scan2int+0x7b>
lea    -0xd0(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     11ab <scan2int+0x7b>
movq   $0xffffffffffffffff,-0xd8(%rbp)
ff ff ff ff
mov    -0xd8(%rbp),%rax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scan2int>:
push   %rbx
sub    $0xd0,%rsp
lea    0xec1(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <strtol@plt>
test   %rax,%rax
jne    1173 <scan2int+0x43>
lea    0xe9e(%rip),%rsi
mov    %rsp,%rdi
call   1030 <strcmp@plt>
neg    %rax
sbb    %rax,%rax
add    $0xd0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"0\00"
define i32 @scan2int() {
%1 = alloca [200 x i8]
%2 = alloca i64
store i64 0, i64* %2
%3 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%6 = call i64 @strtol(i8* %5, i32* null, i32 10)
store i64 %6, i64* %2
%7 = load i64, i64* %2
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %0
%10 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %9
store i64 -1, i64* %2
br label %14
14: ; preds = %13, %9, %0
%15 = load i64, i64* %2
%16 = trunc i64 %15 to i32
ret i32 %16
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"0\00"
define i32 @scan2int() {
%1 = alloca [200 x i8]
%2 = getelementptr inbounds [200 x i8], [200 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 i64 @strtol(i8* nocapture %2, i32* null, i32 10)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp ne i64 %7, 0
%9 = sext i1 %8 to i64
br label %10
10: ; preds = %6, %0
%11 = phi i64 [ %4, %0 ], [ %9, %6 ]
%12 = trunc i64 %11 to i32
ret i32 %12
}