#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 */
struct termios {
  int /*<<< orphan*/ c_cflag;
};

/* Variables and functions */
int /*<<< orphan*/ CSTOPB;
scalar_t__ strcmp(char const *, char *);
void set_stopbit(struct termios *opt, const char *stopbit) {
  if (0 == strcmp(stopbit, "1")) {
    opt->c_cflag &= ~CSTOPB;
  } else if (0 == strcmp(stopbit, "1.5")) {
    opt->c_cflag &= ~CSTOPB;
  } else if (0 == strcmp(stopbit, "2")) {
    opt->c_cflag |= CSTOPB;
  } else {
    opt->c_cflag &= ~CSTOPB;
  }
}


x86 assembly (clang, -O0):
<set_stopbit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed5(%rip),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1157 <set_stopbit+0x47>
mov    0x2e93(%rip),%rax
mov    (%rax),%ecx
xor    $0xffffffff,%ecx
mov    -0x8(%rbp),%rax
and    (%rax),%ecx
mov    %ecx,(%rax)
jmp    11e0 <set_stopbit+0xd0>
mov    -0x10(%rbp),%rdi
lea    0xea0(%rip),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    118e <set_stopbit+0x7e>
mov    0x2e5c(%rip),%rax
mov    (%rax),%ecx
xor    $0xffffffff,%ecx
mov    -0x8(%rbp),%rax
and    (%rax),%ecx
mov    %ecx,(%rax)
jmp    11db <set_stopbit+0xcb>
mov    -0x10(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    11c2 <set_stopbit+0xb2>
mov    0x2e25(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
jmp    11d6 <set_stopbit+0xc6>
mov    0x2e0f(%rip),%rax
mov    (%rax),%ecx
xor    $0xffffffff,%ecx
mov    -0x8(%rbp),%rax
and    (%rax),%ecx
mov    %ecx,(%rax)
jmp    11db <set_stopbit+0xcb>
jmp    11e0 <set_stopbit+0xd0>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_stopbit>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xedf(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1166 <set_stopbit+0x56>
lea    0xecd(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1166 <set_stopbit+0x56>
lea    0xebd(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
mov    0x2e80(%rip),%rcx
mov    (%rcx),%ecx
test   %rax,%rax
je     1176 <set_stopbit+0x66>
not    %ecx
and    %ecx,(%r14)
jmp    1179 <set_stopbit+0x69>
mov    0x2e6b(%rip),%rax
mov    (%rax),%eax
not    %eax
and    %eax,(%r14)
jmp    1179 <set_stopbit+0x69>
or     %ecx,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.termios = type { i32 }
@.str = [2 x i8] c"1\00"
@CSTOPB = global i32 0
@.str.1 = [4 x i8] c"1.5\00"
@.str.2 = [2 x i8] c"2\00"
define void @set_stopbit(%struct.termios* %0, i8* %1) {
%3 = alloca %struct.termios*
%4 = alloca i8*
store %struct.termios* %0, %struct.termios** %3
store i8* %1, i8** %4
%5 = load i8*, i8** %4
%6 = call i64 @strcmp(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 0, %6
br i1 %7, label %8, label %15
8: ; preds = %2
%9 = load i32, i32* @CSTOPB
%10 = xor i32 %9, -1
%11 = load %struct.termios*, %struct.termios** %3
%12 = getelementptr inbounds %struct.termios, %struct.termios* %11, i32 0, i32 0
%13 = load i32, i32* %12
%14 = and i32 %13, %10
store i32 %14, i32* %12
br label %45
15: ; preds = %2
%16 = load i8*, i8** %4
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 0, %17
br i1 %18, label %19, label %26
19: ; preds = %15
%20 = load i32, i32* @CSTOPB
%21 = xor i32 %20, -1
%22 = load %struct.termios*, %struct.termios** %3
%23 = getelementptr inbounds %struct.termios, %struct.termios* %22, i32 0, i32 0
%24 = load i32, i32* %23
%25 = and i32 %24, %21
store i32 %25, i32* %23
br label %44
26: ; preds = %15
%27 = load i8*, i8** %4
%28 = call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%29 = icmp eq i64 0, %28
br i1 %29, label %30, label %36
30: ; preds = %26
%31 = load i32, i32* @CSTOPB
%32 = load %struct.termios*, %struct.termios** %3
%33 = getelementptr inbounds %struct.termios, %struct.termios* %32, i32 0, i32 0
%34 = load i32, i32* %33
%35 = or i32 %34, %31
store i32 %35, i32* %33
br label %43
36: ; preds = %26
%37 = load i32, i32* @CSTOPB
%38 = xor i32 %37, -1
%39 = load %struct.termios*, %struct.termios** %3
%40 = getelementptr inbounds %struct.termios, %struct.termios* %39, i32 0, i32 0
%41 = load i32, i32* %40
%42 = and i32 %41, %38
store i32 %42, i32* %40
br label %43
43: ; preds = %36, %30
br label %44
44: ; preds = %43, %19
br label %45
45: ; preds = %44, %8
ret void
}

LLVM IR (-O2):
%struct.termios = type { i32 }
@.str = [2 x i8] c"1\00"
@CSTOPB = global i32 0
@.str.1 = [4 x i8] c"1.5\00"
@.str.2 = [2 x i8] c"2\00"
define void @set_stopbit(%struct.termios* nocapture %0, i8* %1) {
%3 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %11
5: ; preds = %2
%6 = load i32, i32* @CSTOPB
%7 = xor i32 %6, -1
%8 = getelementptr inbounds %struct.termios, %struct.termios* %0, i64 0, i32 0
%9 = load i32, i32* %8
%10 = and i32 %9, %7
store i32 %10, i32* %8
br label %33
11: ; preds = %2
%12 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %11
%15 = load i32, i32* @CSTOPB
%16 = xor i32 %15, -1
%17 = getelementptr inbounds %struct.termios, %struct.termios* %0, i64 0, i32 0
%18 = load i32, i32* %17
%19 = and i32 %18, %16
store i32 %19, i32* %17
br label %33
20: ; preds = %11
%21 = tail call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
%23 = load i32, i32* @CSTOPB
br i1 %22, label %24, label %28
24: ; preds = %20
%25 = getelementptr inbounds %struct.termios, %struct.termios* %0, i64 0, i32 0
%26 = load i32, i32* %25
%27 = or i32 %26, %23
store i32 %27, i32* %25
br label %33
28: ; preds = %20
%29 = xor i32 %23, -1
%30 = getelementptr inbounds %struct.termios, %struct.termios* %0, i64 0, i32 0
%31 = load i32, i32* %30
%32 = and i32 %31, %29
store i32 %32, i32* %30
br label %33
33: ; preds = %14, %28, %24, %5
ret void
}