#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 first_single(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main(void) {
  char first;
  char string[100];
  printf("Please input string:");
  scanf("%s", string);
  printf("get the string:%s\n", string);
  first = first_single(string);
  if (first)
    printf("The first single char is %c\n", first);
  else
    printf("no result!");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xebd(%rip),%rdi
call   1040 <scanf@plt>
lea    -0x70(%rbp),%rsi
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
call   1050 <first_single@plt>
mov    %al,-0x5(%rbp)
cmpb   $0x0,-0x5(%rbp)
je     119c <main+0x6c>
movsbl -0x5(%rbp),%esi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11aa <main+0x7a>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x70,%rsp
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1040 <scanf@plt>
lea    0xebc(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1050 <first_single@plt>
test   %al,%al
je     1185 <main+0x55>
movsbl %al,%esi
lea    0xeaf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1193 <main+0x63>
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Please input string:\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [19 x i8] c"get the string:%s\0A\00"
@.str.3 = [29 x i8] c"The first single char is %c\0A\00"
@.str.4 = [11 x i8] c"no result!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [100 x i8]
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%10 = call signext i8 @first_single(i8* %9)
store i8 %10, i8* %2
%11 = load i8, i8* %2
%12 = icmp ne i8 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %0
%14 = load i8, i8* %2
%15 = sext i8 %14 to i32
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %15)
br label %19
17: ; preds = %0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %19
19: ; preds = %17, %13
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"Please input string:\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [19 x i8] c"get the string:%s\0A\00"
@.str.3 = [29 x i8] c"The first single char is %c\0A\00"
@.str.4 = [11 x i8] c"no result!\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%6 = call signext i8 @first_single(i8* %2)
%7 = icmp eq i8 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %0
%9 = sext i8 %6 to i32
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %9)
br label %13
11: ; preds = %0
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %13
13: ; preds = %11, %8
ret i32 0
}