#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 */
unsigned int atoi(char const *);
scalar_t__ strcmp(char const *, char *);
int xserial_set_baudrate(unsigned int);
unsigned xserial_set_baud(const char *baud) {
  unsigned baudrate = atoi(baud);
  if (strcmp(baud, "mica2") == 0)
    return xserial_set_baudrate(57600);
  if (strcmp(baud, "mica2dot") == 0)
    return xserial_set_baudrate(19200);
  return xserial_set_baudrate(baudrate);
}


x86 assembly (clang, -O0):
<xserial_set_baud>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xead(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1174 <xserial_set_baud+0x44>
mov    $0xe100,%edi
call   1030 <xserial_set_baudrate@plt>
mov    %eax,-0x4(%rbp)
jmp    11ab <xserial_set_baud+0x7b>
mov    -0x10(%rbp),%rdi
lea    0xe87(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11a0 <xserial_set_baud+0x70>
mov    $0x4b00,%edi
call   1030 <xserial_set_baudrate@plt>
mov    %eax,-0x4(%rbp)
jmp    11ab <xserial_set_baud+0x7b>
mov    -0x14(%rbp),%edi
call   1030 <xserial_set_baudrate@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xserial_set_baud>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1050 <atoi@plt>
mov    %eax,%ebp
lea    0xebc(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     116d <xserial_set_baud+0x3d>
lea    0xeae(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
mov    $0x4b00,%eax
cmove  %eax,%ebp
jmp    1172 <xserial_set_baud+0x42>
mov    $0xe100,%ebp
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <xserial_set_baudrate@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"mica2\00"
@.str.1 = [9 x i8] c"mica2dot\00"
define i32 @xserial_set_baud(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @atoi(i8* %5)
store i32 %6, i32* %4
%7 = load i8*, i8** %3
%8 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = call i32 @xserial_set_baudrate(i32 57600)
store i32 %11, i32* %2
br label %21
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = call i32 @xserial_set_baudrate(i32 19200)
store i32 %17, i32* %2
br label %21
18: ; preds = %12
%19 = load i32, i32* %4
%20 = call i32 @xserial_set_baudrate(i32 %19)
store i32 %20, i32* %2
br label %21
21: ; preds = %18, %16, %10
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
@.str = [6 x i8] c"mica2\00"
@.str.1 = [9 x i8] c"mica2dot\00"
define i32 @xserial_set_baud(i8* %0) {
%2 = tail call i32 @atoi(i8* %0)
%3 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %9, label %5
5: ; preds = %1
%6 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
%8 = select i1 %7, i32 19200, i32 %2
br label %9
9: ; preds = %5, %1
%10 = phi i32 [ 57600, %1 ], [ %8, %5 ]
%11 = tail call i32 @xserial_set_baudrate(i32 %10)
ret i32 %11
}