#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 */
float atof(char *);
int atoi(char *);
long atol(char *);
int /*<<< orphan*/ printf(char *, char);
char tolower(char);
char toupper(char);
int smp_test_str2number() {
  int num = atoi("-12q3a");
  printf("%d\n", num);
  long num1 = atol("123444");
  printf("num1 %ld\n", num1);
  float num3 = atof("123.34");
  ;
  printf("num3 %0.2f\n", num3);
  char c = 'A';
  c = toupper(c);
  printf("chr2upper  %c\n", c);
  c = tolower(c);
  printf("chr2lower  %c\n", c);
  return (0);
}


x86 assembly (clang, -O0):
<smp_test_str2number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe91(%rip),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x4(%rbp)
movsbl -0x4(%rbp),%esi
lea    0xe85(%rip),%rdi
call   1050 <printf@plt>
lea    0xe7d(%rip),%rdi
call   1070 <atol@plt>
mov    %rax,-0x10(%rbp)
movsbl -0x10(%rbp),%esi
lea    0xe70(%rip),%rdi
call   1050 <printf@plt>
lea    0xe6e(%rip),%rdi
call   1040 <atof@plt>
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvttss2si %xmm0,%eax
lea    0xe5b(%rip),%rdi
movsbl %al,%esi
call   1050 <printf@plt>
movb   $0x41,-0x15(%rbp)
movsbl -0x15(%rbp),%edi
call   1030 <toupper@plt>
mov    %al,-0x15(%rbp)
lea    0xe48(%rip),%rdi
movsbl -0x15(%rbp),%esi
call   1050 <printf@plt>
movsbl -0x15(%rbp),%edi
call   1060 <tolower@plt>
mov    %al,-0x15(%rbp)
lea    0xe3b(%rip),%rdi
movsbl -0x15(%rbp),%esi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<smp_test_str2number>:
push   %rbx
lea    0xea8(%rip),%rdi
call   1070 <atoi@plt>
movsbl %al,%esi
lea    0xea0(%rip),%rdi
call   1050 <printf@plt>
lea    0xe98(%rip),%rdi
mov    $0x34,%esi
call   1050 <printf@plt>
lea    0xe91(%rip),%rdi
call   1040 <atof@plt>
cvttss2si %xmm0,%eax
movsbl %al,%esi
lea    0xe85(%rip),%rdi
call   1050 <printf@plt>
mov    $0x41,%edi
call   1030 <toupper@plt>
movsbl %al,%ebx
lea    0xe78(%rip),%rdi
mov    %ebx,%esi
call   1050 <printf@plt>
mov    %ebx,%edi
call   1060 <tolower@plt>
movsbl %al,%esi
lea    0xe6f(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"-12q3a\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.2 = [7 x i8] c"123444\00"
@.str.3 = [10 x i8] c"num1 %ld\0A\00"
@.str.4 = [7 x i8] c"123.34\00"
@.str.5 = [12 x i8] c"num3 %0.2f\0A\00"
@.str.6 = [15 x i8] c"chr2upper %c\0A\00"
@.str.7 = [15 x i8] c"chr2lower %c\0A\00"
define i32 @smp_test_str2number() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca float
%4 = alloca i8
%5 = call i32 @atoi(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i32 %5, i32* %1
%6 = load i32, i32* %1
%7 = trunc i32 %6 to i8
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8 signext %7)
%9 = call i64 @atol(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i64 %9, i64* %2
%10 = load i64, i64* %2
%11 = trunc i64 %10 to i8
%12 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8 signext %11)
%13 = call float @atof(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
store float %13, float* %3
%14 = load float, float* %3
%15 = fptosi float %14 to i8
%16 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8 signext %15)
store i8 65, i8* %4
%17 = load i8, i8* %4
%18 = call signext i8 @toupper(i8 signext %17)
store i8 %18, i8* %4
%19 = load i8, i8* %4
%20 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8 signext %19)
%21 = load i8, i8* %4
%22 = call signext i8 @tolower(i8 signext %21)
store i8 %22, i8* %4
%23 = load i8, i8* %4
%24 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8 signext %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"-12q3a\00"
@.str.1 = [4 x i8] c"%d\0A\00"
@.str.3 = [10 x i8] c"num1 %ld\0A\00"
@.str.4 = [7 x i8] c"123.34\00"
@.str.5 = [12 x i8] c"num3 %0.2f\0A\00"
@.str.6 = [15 x i8] c"chr2upper %c\0A\00"
@.str.7 = [15 x i8] c"chr2lower %c\0A\00"
define i32 @smp_test_str2number() {
%1 = tail call i32 @atoi(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%2 = trunc i32 %1 to i8
%3 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8 signext %2)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8 signext 52)
%5 = tail call float @atof(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%6 = fptosi float %5 to i8
%7 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i8 signext %6)
%8 = tail call signext i8 @toupper(i8 signext 65)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8 signext %8)
%10 = tail call signext i8 @tolower(i8 signext %8)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), i8 signext %10)
ret i32 0
}