#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main(void) {
  char word[10];
  char c;
  printf("enter a word: ");
  scanf("%9s", word);
  printf("enter any character: ");
  do {
    c = getchar();
  } while (c == '\n');
  if (c == '\n')
    printf("warning: char c contains a newline\n");
  printf("you entered: word: %s, char: %c\n", word, c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xe(%rbp),%rsi
lea    0xeb7(%rip),%rdi
call   1050 <scanf@plt>
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0xf(%rbp)
movsbl -0xf(%rbp),%eax
cmp    $0xa,%eax
je     116b <main+0x3b>
movsbl -0xf(%rbp),%eax
cmp    $0xa,%eax
jne    119d <main+0x6d>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0xe(%rbp),%rsi
movsbl -0xf(%rbp),%edx
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xec6(%rip),%rdi
lea    0xe(%rsp),%rsi
call   1050 <scanf@plt>
lea    0xeb9(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
cmp    $0xa,%al
je     1170 <main+0x40>
movsbl %al,%edx
lea    0xea4(%rip),%rdi
lea    0xe(%rsp),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"enter a word: \00"
@.str.1 = [4 x i8] c"%9s\00"
@.str.2 = [22 x i8] c"enter any character: \00"
@.str.3 = [36 x i8] c"warning: char c contains a newline\0A\00"
@.str.4 = [33 x i8] c"you entered: word: %s, char: %c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca i8
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %8
8: ; preds = %10, %0
%9 = call signext i8 (...) @getchar()
store i8 %9, i8* %3
br label %10
10: ; preds = %8
%11 = load i8, i8* %3
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 10
br i1 %13, label %8, label %14
14: ; preds = %10
%15 = load i8, i8* %3
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 10
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
br label %20
20: ; preds = %18, %14
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%22 = load i8, i8* %3
%23 = sext i8 %22 to i32
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i8* %21, i32 %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"enter a word: \00"
@.str.1 = [4 x i8] c"%9s\00"
@.str.2 = [22 x i8] c"enter any character: \00"
@.str.4 = [33 x i8] c"you entered: word: %s, char: %c\0A\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %6
6: ; preds = %6, %0
%7 = call signext i8 (...) @getchar()
%8 = icmp eq i8 %7, 10
br i1 %8, label %6, label %9
9: ; preds = %6
%10 = sext i8 %7 to i32
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i8* %2, i32 %10)
ret i32 0
}