#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*/ sscanf(char *, char *, int *);
int get_num(char *num_str) {
  int num;
  if (*num_str == '+')
    sscanf(num_str, "+%d", &num);
  else if (*num_str == '-')
    sscanf(num_str, "-%d", &num);
  else
    sscanf(num_str, "%d", &num);
  return num;
}


x86 assembly (clang, -O0):
<get_num>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2b,%eax
jne    1145 <get_num+0x35>
mov    -0x8(%rbp),%rdi
lea    0xec9(%rip),%rsi
lea    -0xc(%rbp),%rdx
call   1030 <sscanf@plt>
jmp    1187 <get_num+0x77>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    116e <get_num+0x5e>
mov    -0x8(%rbp),%rdi
lea    0xea4(%rip),%rsi
lea    -0xc(%rbp),%rdx
call   1030 <sscanf@plt>
jmp    1182 <get_num+0x72>
mov    -0x8(%rbp),%rdi
lea    0xe88(%rip),%rsi
lea    -0xc(%rbp),%rdx
call   1030 <sscanf@plt>
jmp    1187 <get_num+0x77>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_num>:
push   %rax
mov    (%rdi),%al
cmp    $0x2d,%al
lea    0xee8(%rip),%rcx
lea    0xede(%rip),%rdx
cmove  %rcx,%rdx
cmp    $0x2b,%al
lea    0xed0(%rip),%rsi
cmovne %rdx,%rsi
lea    0x4(%rsp),%rdx
call   1030 <sscanf@plt>
mov    0x4(%rsp),%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"+%d\00"
@.str.1 = [4 x i8] c"-%d\00"
@.str.2 = [3 x i8] c"%d\00"
define i32 @get_num(i8* nocapture %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 45
%6 = select i1 %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%7 = icmp eq i8 %4, 43
%8 = select i1 %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %6
%9 = call i32 @sscanf(i8* %0, i8* %8, i32* %2)
%10 = load i32, i32* %2
ret i32 %10
}