#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*/ atoi(char *);
int /*<<< orphan*/ err(int, char *);
int /*<<< orphan*/ set_numvar(char *, int /*<<< orphan*/);
int /*<<< orphan*/ set_strvar(char *, char *);
void set_var(char *name, char *val) {
  if (name[0] == '$') {
    set_strvar(name, val);
  } else if (name[0] == '#') {
    set_numvar(name, atoi(val));
  } else {
    err(6, name);
  }
}


x86 assembly (clang, -O0):
<set_var>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x24,%eax
jne    1172 <set_var+0x32>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <set_strvar@plt>
jmp    11b6 <set_var+0x76>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
jne    11a3 <set_var+0x63>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <atoi@plt>
mov    -0x18(%rbp),%rdi
mov    %eax,%esi
call   1040 <set_numvar@plt>
jmp    11b1 <set_var+0x71>
mov    -0x8(%rbp),%rsi
mov    $0x6,%edi
call   1050 <err@plt>
jmp    11b6 <set_var+0x76>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_var>:
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%al
cmp    $0x23,%al
je     1157 <set_var+0x17>
cmp    $0x24,%al
jne    116a <set_var+0x2a>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <set_strvar@plt>
mov    %rsi,%rdi
call   1060 <atoi@plt>
mov    %rbx,%rdi
mov    %eax,%esi
pop    %rbx
jmp    1040 <set_numvar@plt>
mov    $0x6,%edi
mov    %rbx,%rsi
pop    %rbx
jmp    1050 <err@plt>

LLVM IR (-O0):
define void @set_var(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %3
%6 = getelementptr inbounds i8, i8* %5, i64 0
%7 = load i8, i8* %6
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 36
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i8*, i8** %3
%12 = load i8*, i8** %4
%13 = call i32 @set_strvar(i8* %11, i8* %12)
br label %29
14: ; preds = %2
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 35
br i1 %19, label %20, label %25
20: ; preds = %14
%21 = load i8*, i8** %3
%22 = load i8*, i8** %4
%23 = call i32 @atoi(i8* %22)
%24 = call i32 @set_numvar(i8* %21, i32 %23)
br label %28
25: ; preds = %14
%26 = load i8*, i8** %3
%27 = call i32 @err(i32 6, i8* %26)
br label %28
28: ; preds = %25, %20
br label %29
29: ; preds = %28, %10
ret void
}

LLVM IR (-O2):
define void @set_var(i8* %0, i8* %1) {
%3 = load i8, i8* %0
switch i8 %3, label %9 [
i8 36, label %4
i8 35, label %6
]
4: ; preds = %2
%5 = tail call i32 @set_strvar(i8* %0, i8* %1)
br label %11
6: ; preds = %2
%7 = tail call i32 @atoi(i8* %1)
%8 = tail call i32 @set_numvar(i8* %0, i32 %7)
br label %11
9: ; preds = %2
%10 = tail call i32 @err(i32 6, i8* %0)
br label %11
11: ; preds = %6, %9, %4
ret void
}