#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 EOF;
int cmatch(int, char *);
int getchar();
int /*<<< orphan*/ printf(char *, int, int);
int main(void) {
  char s[] = "Hello, my darling wife.";
  int c;
  while ((c = getchar()) != EOF) {
    if (c != '\n') {
      printf("First occurrence of [%c] = [%d]\n", c, cmatch(c, s));
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeb4(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %eax,-0x24(%rbp)
mov    0x2e77(%rip),%rcx
cmp    (%rcx),%eax
je     11ab <main+0x7b>
cmpl   $0xa,-0x24(%rbp)
je     11a6 <main+0x76>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1050 <cmatch@plt>
mov    -0x28(%rbp),%esi
mov    %eax,%edx
lea    0xe77(%rip),%rdi
call   1030 <printf@plt>
jmp    1160 <main+0x30>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
movaps 0xebf(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0x2e656669772067,%rax
mov    %rax,0x10(%rsp)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    0x2e86(%rip),%rbx
cmp    (%rbx),%eax
jne    1173 <main+0x43>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebp
mov    %rsp,%r14
lea    0xe99(%rip),%r15
jmp    119d <main+0x6d>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getchar@plt>
mov    %eax,%ebp
cmp    (%rbx),%eax
je     1166 <main+0x36>
cmp    $0xa,%ebp
je     1190 <main+0x60>
mov    %ebp,%edi
mov    %r14,%rsi
call   1050 <cmatch@plt>
mov    %r15,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1030 <printf@plt>
jmp    1190 <main+0x60>

LLVM IR (-O0):
@__const.main.s = [24 x i8] c"Hello, my darling wife.\00"
@EOF = global i32 0
@.str = [33 x i8] c"First occurrence of [%c] = [%d]\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [24 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = bitcast [24 x i8]* %2 to i8*
br label %5
5: ; preds = %18, %0
%6 = call i32 (...) @getchar()
store i32 %6, i32* %3
%7 = load i32, i32* @EOF
%8 = icmp ne i32 %6, %7
br i1 %8, label %9, label %19
9: ; preds = %5
%10 = load i32, i32* %3
%11 = icmp ne i32 %10, 10
br i1 %11, label %12, label %18
12: ; preds = %9
%13 = load i32, i32* %3
%14 = load i32, i32* %3
%15 = getelementptr inbounds [24 x i8], [24 x i8]* %2, i64 0, i64 0
%16 = call i32 @cmatch(i32 %14, i8* %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %16)
br label %18
18: ; preds = %12, %9
br label %5
19: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@__const.main.s = [24 x i8] c"Hello, my darling wife.\00"
@EOF = global i32 0
@.str = [33 x i8] c"First occurrence of [%c] = [%d]\0A\00"
define i32 @main() {
%1 = alloca [24 x i8]
%2 = getelementptr inbounds [24 x i8], [24 x i8]* %1, i64 0, i64 0
%3 = call i32 (...) @getchar()
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %16, label %6
6: ; preds = %0, %12
%7 = phi i32 [ %13, %12 ], [ %3, %0 ]
%8 = icmp eq i32 %7, 10
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = call i32 @cmatch(i32 %7, i8* %2)
%11 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %10)
br label %12
12: ; preds = %9, %6
%13 = call i32 (...) @getchar()
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %6
16: ; preds = %12, %0
ret i32 0
}