#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 c_cflag;
};

/* Variables and functions */
int PARENB;
int PARODD;
unsigned char Termios2TncomParity(struct termios *ti) {
  if ((ti->c_cflag & PARENB) == 0)
    return ((unsigned char)1);
  if ((ti->c_cflag & PARENB) && (ti->c_cflag & PARODD))
    return ((unsigned char)2);
  return ((unsigned char)3);
}


x86 assembly (clang, -O0):
<Termios2TncomParity>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2ed3(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jne    1129 <Termios2TncomParity+0x29>
movb   $0x1,-0x1(%rbp)
jmp    1166 <Termios2TncomParity+0x66>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2eb2(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1162 <Termios2TncomParity+0x62>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    0x2e92(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1162 <Termios2TncomParity+0x62>
movb   $0x2,-0x1(%rbp)
jmp    1166 <Termios2TncomParity+0x66>
movb   $0x3,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<Termios2TncomParity>:
mov    (%rdi),%eax
mov    0x2edf(%rip),%rcx
mov    0x2ed0(%rip),%rdx
test   %eax,(%rdx)
sete   %dl
or     $0x2,%dl
test   %eax,(%rcx)
movzbl %dl,%ecx
mov    $0x1,%eax
cmovne %ecx,%eax
ret

LLVM IR (-O0):
%struct.termios = type { i32 }
@PARENB = global i32 0
@PARODD = global i32 0
define zeroext i8 @Termios2TncomParity(%struct.termios* %0) {
%2 = alloca i8
%3 = alloca %struct.termios*
store %struct.termios* %0, %struct.termios** %3
%4 = load %struct.termios*, %struct.termios** %3
%5 = getelementptr inbounds %struct.termios, %struct.termios* %4, i32 0, i32 0
%6 = load i32, i32* %5
%7 = load i32, i32* @PARENB
%8 = and i32 %6, %7
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
store i8 1, i8* %2
br label %27
11: ; preds = %1
%12 = load %struct.termios*, %struct.termios** %3
%13 = getelementptr inbounds %struct.termios, %struct.termios* %12, i32 0, i32 0
%14 = load i32, i32* %13
%15 = load i32, i32* @PARENB
%16 = and i32 %14, %15
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %26
18: ; preds = %11
%19 = load %struct.termios*, %struct.termios** %3
%20 = getelementptr inbounds %struct.termios, %struct.termios* %19, i32 0, i32 0
%21 = load i32, i32* %20
%22 = load i32, i32* @PARODD
%23 = and i32 %21, %22
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %18
store i8 2, i8* %2
br label %27
26: ; preds = %18, %11
store i8 3, i8* %2
br label %27
27: ; preds = %26, %25, %10
%28 = load i8, i8* %2
ret i8 %28
}

LLVM IR (-O2):
%struct.termios = type { i32 }
@PARENB = global i32 0
@PARODD = global i32 0
define zeroext i8 @Termios2TncomParity(%struct.termios* nocapture %0) {
%2 = getelementptr inbounds %struct.termios, %struct.termios* %0, i64 0, i32 0
%3 = load i32, i32* %2
%4 = load i32, i32* @PARENB
%5 = and i32 %4, %3
%6 = icmp eq i32 %5, 0
%7 = load i32, i32* @PARODD
%8 = and i32 %7, %3
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i8 3, i8 2
%11 = select i1 %6, i8 1, i8 %10
ret i8 %11
}