#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*/ error(char *, char const *);
int /*<<< orphan*/ strcmp(char const *, char *);
int scale_parse(int *scale, const char *str) {
  if (str == NULL) {
    *scale = 1;
  } else {
    if (!strcmp(str, "log")) {
      *scale = 2;
    } else if (!strcmp(str, "linear")) {
      *scale = 1;
    } else if (!strcmp(str, "log-zero")) {
      *scale = 3;
    } else {
      *scale = -1;
      error("Scale specified but not recognized: %s\n", str);
    }
  }
  return (*scale == -1);
}


x86 assembly (clang, -O0):
<scale_parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    114a <scale_parse+0x2a>
mov    -0x8(%rbp),%rax
movl   $0x1,(%rax)
jmp    11eb <scale_parse+0xcb>
mov    -0x10(%rbp),%rdi
lea    0xeab(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1172 <scale_parse+0x52>
mov    -0x8(%rbp),%rax
movl   $0x2,(%rax)
jmp    11e6 <scale_parse+0xc6>
mov    -0x10(%rbp),%rdi
lea    0xe87(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    119a <scale_parse+0x7a>
mov    -0x8(%rbp),%rax
movl   $0x1,(%rax)
jmp    11e1 <scale_parse+0xc1>
mov    -0x10(%rbp),%rdi
lea    0xe66(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11c2 <scale_parse+0xa2>
mov    -0x8(%rbp),%rax
movl   $0x3,(%rax)
jmp    11dc <scale_parse+0xbc>
mov    -0x8(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x10(%rbp),%rsi
lea    0xe3d(%rip),%rdi
call   1040 <error@plt>
jmp    11e1 <scale_parse+0xc1>
jmp    11e6 <scale_parse+0xc6>
jmp    11eb <scale_parse+0xcb>
mov    -0x8(%rbp),%rax
cmpl   $0xffffffff,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scale_parse>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
test   %rsi,%rsi
je     1189 <scale_parse+0x69>
mov    %rsi,%rbx
lea    0xeca(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1192 <scale_parse+0x72>
lea    0xebb(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1189 <scale_parse+0x69>
lea    0xeaf(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     119b <scale_parse+0x7b>
movl   $0xffffffff,(%r14)
lea    0xe9e(%rip),%rdi
mov    %rbx,%rsi
call   1040 <error@plt>
xor    %eax,%eax
cmpl   $0xffffffff,(%r14)
sete   %al
jmp    11a4 <scale_parse+0x84>
movl   $0x1,(%r14)
jmp    11a2 <scale_parse+0x82>
movl   $0x2,(%r14)
jmp    11a2 <scale_parse+0x82>
movl   $0x3,(%r14)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [4 x i8] c"log\00"
@.str.1 = [7 x i8] c"linear\00"
@.str.2 = [9 x i8] c"log-zero\00"
@.str.3 = [40 x i8] c"Scale specified but not recognized: %s\0A\00"
define i32 @scale_parse(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
store i32* %0, i32** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = load i32*, i32** %3
store i32 1, i32* %8
br label %34
9: ; preds = %2
%10 = load i8*, i8** %4
%11 = call i32 @strcmp(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%12 = icmp ne i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %9
%14 = load i32*, i32** %3
store i32 2, i32* %14
br label %33
15: ; preds = %9
%16 = load i8*, i8** %4
%17 = call i32 @strcmp(i8* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp ne i32 %17, 0
br i1 %18, label %21, label %19
19: ; preds = %15
%20 = load i32*, i32** %3
store i32 1, i32* %20
br label %32
21: ; preds = %15
%22 = load i8*, i8** %4
%23 = call i32 @strcmp(i8* %22, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp ne i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %21
%26 = load i32*, i32** %3
store i32 3, i32* %26
br label %31
27: ; preds = %21
%28 = load i32*, i32** %3
store i32 -1, i32* %28
%29 = load i8*, i8** %4
%30 = call i32 @error(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i8* %29)
br label %31
31: ; preds = %27, %25
br label %32
32: ; preds = %31, %19
br label %33
33: ; preds = %32, %13
br label %34
34: ; preds = %33, %7
%35 = load i32*, i32** %3
%36 = load i32, i32* %35
%37 = icmp eq i32 %36, -1
%38 = zext i1 %37 to i32
ret i32 %38
}

LLVM IR (-O2):
@.str = [4 x i8] c"log\00"
@.str.1 = [7 x i8] c"linear\00"
@.str.2 = [9 x i8] c"log-zero\00"
@.str.3 = [40 x i8] c"Scale specified but not recognized: %s\0A\00"
define i32 @scale_parse(i32* nocapture %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %4, label %5
4: ; preds = %2
store i32 1, i32* %0
br label %22
5: ; preds = %2
%6 = tail call i32 @strcmp(i8* %1, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %5
store i32 2, i32* %0
br label %22
9: ; preds = %5
%10 = tail call i32 @strcmp(i8* %1, i8* dereferenceable(7) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %9
store i32 1, i32* %0
br label %22
13: ; preds = %9
%14 = tail call i32 @strcmp(i8* %1, i8* dereferenceable(9) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %13
store i32 3, i32* %0
br label %22
17: ; preds = %13
store i32 -1, i32* %0
%18 = tail call i32 @error(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i8* %1)
%19 = load i32, i32* %0
%20 = icmp eq i32 %19, -1
%21 = zext i1 %20 to i32
br label %22
22: ; preds = %8, %16, %17, %12, %4
%23 = phi i32 [ 0, %8 ], [ 0, %16 ], [ %21, %17 ], [ 0, %12 ], [ 0, %4 ]
ret i32 %23
}