#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 */
typedef int /*<<< orphan*/ a;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ strcat(char *, char *);
char *strchr(char *, char);
int strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strrchr(char *, char);
char *strstr(char *, char *);
int main() {
  char a[100] = "hello world!";
  printf("%d\n", sizeof("hello world!"));
  strcpy(a, " good afternoon!");
  puts(a);
  strcat(a, " dear friends!");
  puts(a);
  printf("%d,%d\n", sizeof(a), strlen(a));
  printf("%p\n", strchr(a, 'o'));
  printf("%p\n", strrchr(a, 'o'));
  printf("%s\n", strchr(a, 'r'));
  printf("%s", strchr(a, 'k'));
  printf("%s\n", strstr(a, "ie"));
  printf("===========%s\n", a);
  int n = strcmp(a, "good afternoon");
  printf("%p,%p\n", a, "good afternoon");
  if (!n)
    printf("相等\n");
  else if (n == -1)
    printf("數組a小\n");
  else
    printf("數組a大\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xe43(%rip),%rsi
mov    $0x64,%edx
call   10a0 <memcpy@plt>
lea    0xeb9(%rip),%rdi
mov    $0xd,%esi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    0xe7f(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x70(%rbp),%rdi
call   1040 <puts@plt>
lea    -0x70(%rbp),%rdi
lea    0xe77(%rip),%rsi
call   10b0 <strcat@plt>
lea    -0x70(%rbp),%rdi
call   1040 <puts@plt>
lea    -0x70(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%edx
lea    0xe66(%rip),%rdi
mov    $0x64,%esi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    $0x6f,%esi
call   1060 <strchr@plt>
mov    %rax,%rsi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    $0x6f,%esi
call   1080 <strrchr@plt>
mov    %eax,%esi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    $0x72,%esi
call   1060 <strchr@plt>
mov    %rax,%rsi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    $0x6b,%esi
call   1060 <strchr@plt>
mov    %rax,%rsi
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    0xdde(%rip),%rsi
call   10c0 <strstr@plt>
mov    %rax,%rsi
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    0xdbd(%rip),%rsi
call   1090 <strcmp@plt>
mov    %eax,-0x74(%rbp)
lea    -0x70(%rbp),%rsi
lea    0xdb9(%rip),%rdi
lea    0xda3(%rip),%rdx
mov    $0x0,%al
call   1070 <printf@plt>
cmpl   $0x0,-0x74(%rbp)
jne    1321 <main+0x181>
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1351 <main+0x1b1>
cmpl   $0xffffffff,-0x74(%rbp)
jne    133e <main+0x19e>
lea    0xd8c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    134c <main+0x1ac>
lea    0xd85(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1351 <main+0x1b1>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
movaps 0xeb1(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xe95(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe79(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe5d(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe41(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe25(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
lea    0xe99(%rip),%rdi
mov    $0xd,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe63(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
lea    0xe5a(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcat@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
lea    0xe4a(%rip),%rdi
mov    $0x64,%esi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    $0x6f,%esi
call   1060 <strchr@plt>
lea    0xe56(%rip),%r14
mov    %r14,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    $0x6f,%esi
call   1080 <strrchr@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
mov    $0x72,%esi
call   1060 <strchr@plt>
mov    %rax,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
mov    $0x6b,%esi
call   1060 <strchr@plt>
lea    0xde0(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdd2(%rip),%rsi
mov    %rbx,%rdi
call   10b0 <strstr@plt>
mov    %rax,%rdi
call   1040 <puts@plt>
lea    0xdbe(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xdbc(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1090 <strcmp@plt>
mov    %eax,%ebp
lea    0xdb7(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
cmp    $0xffffffff,%ebp
lea    0xdb9(%rip),%rax
lea    0xda7(%rip),%rcx
cmove  %rax,%rcx
test   %ebp,%ebp
lea    0xd93(%rip),%rdi
cmovne %rcx,%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.a = [100 x i8] c"hello world!\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [17 x i8] c" good afternoon!\00"
@.str.2 = [15 x i8] c" dear friends!\00"
@.str.3 = [7 x i8] c"%d,%d\0A\00"
@.str.4 = [4 x i8] c"%p\0A\00"
@.str.5 = [4 x i8] c"%s\0A\00"
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [3 x i8] c"ie\00"
@.str.8 = [15 x i8] c"===========%s\0A\00"
@.str.9 = [15 x i8] c"good afternoon\00"
@.str.10 = [7 x i8] c"%p,%p\0A\00"
@.str.11 = [8 x i8] c"\E7\9B\B8\E7\AD\89\0A\00"
@.str.12 = [12 x i8] c"\E6\95\B8\E7\B5\84a\E5\B0\8F\0A\00"
@.str.13 = [12 x i8] c"\E6\95\B8\E7\B5\84a\E5\A4\A7\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = bitcast [100 x i8]* %2 to i8*
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 13)
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%9 = call i32 @puts(i8* %8)
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%11 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%13 = call i32 @puts(i8* %12)
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i64 100, i32 %15)
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%18 = call i8* @strchr(i8* %17, i8 signext 111)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %18)
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%21 = call i32 @strrchr(i8* %20, i8 signext 111)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%24 = call i8* @strchr(i8* %23, i8 signext 114)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %24)
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%27 = call i8* @strchr(i8* %26, i8 signext 107)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %27)
%29 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%30 = call i8* @strstr(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* %32)
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%35 = call i32 @strcmp(i8* %34, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
store i32 %35, i32* %3
%36 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* %36, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%38 = load i32, i32* %3
%39 = icmp ne i32 %38, 0
br i1 %39, label %42, label %40
40: ; preds = %0
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.11, i64 0, i64 0))
br label %50
42: ; preds = %0
%43 = load i32, i32* %3
%44 = icmp eq i32 %43, -1
br i1 %44, label %45, label %47
45: ; preds = %42
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
br label %49
47: ; preds = %42
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.13, i64 0, i64 0))
br label %49
49: ; preds = %47, %45
br label %50
50: ; preds = %49, %40
ret i32 0
}

LLVM IR (-O2):
@__const.main.a = [100 x i8] c"hello world!\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [17 x i8] c" good afternoon!\00"
@.str.2 = [15 x i8] c" dear friends!\00"
@.str.3 = [7 x i8] c"%d,%d\0A\00"
@.str.4 = [4 x i8] c"%p\0A\00"
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [3 x i8] c"ie\00"
@.str.8 = [15 x i8] c"===========%s\0A\00"
@.str.9 = [15 x i8] c"good afternoon\00"
@.str.10 = [7 x i8] c"%p,%p\0A\00"
@str = [7 x i8] c"\E7\9B\B8\E7\AD\89\00"
@str.14 = [11 x i8] c"\E6\95\B8\E7\B5\84a\E5\A4\A7\00"
@str.15 = [11 x i8] c"\E6\95\B8\E7\B5\84a\E5\B0\8F\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 ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 13)
%4 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @puts(i8* %2)
%6 = call i32 @strcat(i8* %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @puts(i8* %2)
%8 = call i32 @strlen(i8* %2)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i64 100, i32 %8)
%10 = call i8* @strchr(i8* %2, i8 signext 111)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %10)
%12 = call i32 @strrchr(i8* %2, i8 signext 111)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %12)
%14 = call i8* @strchr(i8* %2, i8 signext 114)
%15 = call i32 @puts(i8* dereferenceable(1) %14)
%16 = call i8* @strchr(i8* %2, i8 signext 107)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %16)
%18 = call i8* @strstr(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%19 = call i32 @puts(i8* dereferenceable(1) %18)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* %2)
%21 = call i32 @strcmp(i8* %2, i8* dereferenceable(15) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0), i8* %2, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%23 = icmp eq i32 %21, -1
%24 = select i1 %23, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @str.15, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @str.14, i64 0, i64 0)
%25 = icmp eq i32 %21, 0
%26 = select i1 %25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0), i8* %24
%27 = call i32 @puts(i8* dereferenceable(1) %26)
ret i32 0
}