#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 *find_char(char, char *);
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  char *p, ch;
  char s[40] = "abcdefghijklmnopqrstuvwxyz";
  printf("Please input a char:\n");
  ch = getchar();
  p = find_char(ch, s);
  printf("%s\n", s);
  if (*p)
    printf("%s\n", p);
  else
    printf("No match found.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x28,%edx
call   1050 <memcpy@plt>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
lea    -0x40(%rbp),%rsi
movsbl %al,%edi
call   1060 <find_char@plt>
mov    %rax,-0x10(%rbp)
lea    -0x40(%rbp),%rsi
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11c5 <main+0x85>
mov    -0x10(%rbp),%rsi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d3 <main+0x93>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movaps 0xed2(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeb6(%rip),%xmm0
movaps %xmm0,(%rsp)
movq   $0x0,0x20(%rsp)
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
movsbl %al,%edi
mov    %rsp,%r14
mov    %r14,%rsi
call   1050 <find_char@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1030 <puts@plt>
cmpb   $0x0,(%rbx)
je     118d <main+0x5d>
mov    %rbx,%rdi
jmp    1194 <main+0x64>
lea    0xea9(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.s = [40 x i8] c"abcdefghijklmnopqrstuvwxyz\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [22 x i8] c"Please input a char:\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [17 x i8] c"No match found.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8
%4 = alloca [40 x i8]
store i32 0, i32* %1
%5 = bitcast [40 x i8]* %4 to i8*
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%7 = call signext i8 (...) @getchar()
store i8 %7, i8* %3
%8 = load i8, i8* %3
%9 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%10 = call i8* @find_char(i8 signext %8, i8* %9)
store i8* %10, i8** %2
%11 = getelementptr inbounds [40 x i8], [40 x i8]* %4, i64 0, i64 0
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = load i8*, i8** %2
%14 = load i8, i8* %13
%15 = icmp ne i8 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %0
%17 = load i8*, i8** %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %17)
br label %21
19: ; preds = %0
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %16
ret i32 0
}

LLVM IR (-O2):
@__const.main.s = [40 x i8] c"abcdefghijklmnopqrstuvwxyz\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@str = [21 x i8] c"Please input a char:\00"
@str.3 = [16 x i8] c"No match found.\00"
define i32 @main() {
%1 = alloca [40 x i8]
%2 = getelementptr inbounds [40 x i8], [40 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%4 = tail call signext i8 (...) @getchar()
%5 = call i8* @find_char(i8 signext %4, i8* %2)
%6 = call i32 @puts(i8* %2)
%7 = load i8, i8* %5
%8 = icmp eq i8 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %0
%10 = call i32 @puts(i8* %5)
br label %13
11: ; preds = %0
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.3, i64 0, i64 0))
br label %13
13: ; preds = %11, %9
ret i32 0
}