#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 atoi(char *);
int /*<<< orphan*/ getline(char *, int);
int /*<<< orphan*/ goodbaud(int);
int /*<<< orphan*/ printf(char *);
void setbaud() {
  int baud;
  char buffer[20];
  buffer[0] = '\0';
  do {
    printf("\nEnter default modem bit rate:  ");
    getline(buffer, 6);
    if (!buffer[0])
      break;
    baud = atoi(buffer);
    printf("\n");
  } while (!goodbaud(baud));
}


x86 assembly (clang, -O0):
<setbaud>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movb   $0x0,-0x20(%rbp)
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
lea    -0x20(%rbp),%rdi
mov    $0x6,%esi
call   1060 <getline@plt>
cmpb   $0x0,-0x20(%rbp)
jne    1175 <setbaud+0x35>
jmp    11a5 <setbaud+0x65>
lea    -0x20(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x4(%rbp)
lea    0xe99(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
call   1040 <goodbaud@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    114c <setbaud+0xc>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setbaud>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
movb   $0x0,(%rsp)
lea    0xe9d(%rip),%r14
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1070 <getline@plt>
cmpb   $0x0,(%rsp)
je     11aa <setbaud+0x5a>
mov    %rbx,%rdi
call   1060 <atoi@plt>
mov    %eax,%ebp
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %ebp,%edi
call   1050 <goodbaud@plt>
test   %eax,%eax
je     1170 <setbaud+0x20>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"\0AEnter default modem bit rate: \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @setbaud() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
store i8 0, i8* %3
br label %4
4: ; preds = %16, %0
%5 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%7 = call i32 @getline(i8* %6, i32 6)
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %4
br label %21
12: ; preds = %4
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%14 = call i32 @atoi(i8* %13)
store i32 %14, i32* %1
%15 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %12
%17 = load i32, i32* %1
%18 = call i32 @goodbaud(i32 %17)
%19 = icmp ne i32 %18, 0
%20 = xor i1 %19, true
br i1 %20, label %4, label %21
21: ; preds = %16, %11
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"\0AEnter default modem bit rate: \00"
define void @setbaud() {
%1 = alloca [20 x i8]
%2 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
store i8 0, i8* %2
br label %3
3: ; preds = %8, %0
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @getline(i8* %2, i32 6)
%6 = load i8, i8* %2
%7 = icmp eq i8 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %3
%9 = call i32 @atoi(i8* %2)
%10 = call i32 @putchar(i32 10)
%11 = call i32 @goodbaud(i32 %9)
%12 = icmp eq i32 %11, 0
br i1 %12, label %3, label %13
13: ; preds = %3, %8
ret void
}