#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, char *, char *);
void fig09_20() {
  char x;
  char y[9];
  printf("%s", "Enter a string: ");
  scanf("%c%8s", &x, y);
  puts("The input was:\n");
  printf("the character \"%c\" and the string \"%s\"\n", x, y);
}


x86 assembly (clang, -O0):
<fig09_20>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
lea    0xebd(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xa(%rbp),%rdx
lea    0xebc(%rip),%rdi
lea    -0x1(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
movsbl -0x1(%rbp),%esi
lea    -0xa(%rbp),%rdx
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fig09_20>:
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rdi
lea    0xec0(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec3(%rip),%rdi
lea    0x6(%rsp),%rsi
lea    0x7(%rsp),%rbx
mov    %rbx,%rdx
call   1050 <scanf@plt>
lea    0xeb0(%rip),%rdi
call   1030 <puts@plt>
movsbl 0x6(%rsp),%esi
lea    0xeaf(%rip),%rdi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [17 x i8] c"Enter a string: \00"
@.str.2 = [6 x i8] c"%c%8s\00"
@.str.3 = [16 x i8] c"The input was:\0A\00"
@.str.4 = [40 x i8] c"the character \22%c\22 and the string \22%s\22\0A\00"
define void @fig09_20() {
%1 = alloca i8
%2 = alloca [9 x i8]
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%4 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %1, i8* %4)
%6 = call i32 @puts(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%7 = load i8, i8* %1
%8 = sext i8 %7 to i32
%9 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %8, i8* %9)
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [17 x i8] c"Enter a string: \00"
@.str.2 = [6 x i8] c"%c%8s\00"
@.str.3 = [16 x i8] c"The input was:\0A\00"
@.str.4 = [40 x i8] c"the character \22%c\22 and the string \22%s\22\0A\00"
define void @fig09_20() {
%1 = alloca i8
%2 = alloca [9 x i8]
%3 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %1, i8* %3)
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%7 = load i8, i8* %1
%8 = sext i8 %7 to i32
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0), i32 %8, i8* %3)
ret void
}