#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 atoi(char *);
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ printf(char *, int);
int startup(int);
int /*<<< orphan*/ wait_client(int);
int main(int argc, char **argv) {
  int port, listenfd;
  if (argc != 2) {
    error("请指定端口号\n\tExample: ./tiny 8000\n");
  }
  port = atoi(argv[1]);
  listenfd = startup(port);
  printf("listen on %d port ...\n", port);
  wait_client(listenfd);
  char *s1 = "Hello world";
  char s2[] = "Hello world";
  s1[2] = 'E';
  s2[2] = 'E';
  *(s1 + 2) = 'E';
  *(s2 + 2) = 'E';
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     117c <main+0x2c>
lea    0xe89(%rip),%rdi
call   1060 <error@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1050 <startup@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%edi
call   1040 <wait_client@plt>
lea    0xe8c(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe81(%rip),%rax
mov    %rax,-0x2c(%rbp)
mov    0xe7f(%rip),%eax
mov    %eax,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x45,0x2(%rax)
movb   $0x45,-0x2a(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x45,0x2(%rax)
movb   $0x45,-0x2a(%rbp)
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
je     1167 <main+0x17>
lea    0xe9e(%rip),%rdi
call   1060 <error@plt>
mov    0x8(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1050 <startup@plt>
mov    %eax,%ebp
lea    0xea8(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %ebp,%edi
call   1040 <wait_client@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [42 x i8] c"\E8\AF\B7\E6\8C\87\E5\AE\9A\E7\AB\AF\E5\8F\A3\E5\8F\B7\0A\09Example: ./tiny 8000\0A\00"
@.str.1 = [23 x i8] c"listen on %d port ...\0A\00"
@.str.2 = [12 x i8] c"Hello world\00"
@__const.main.s2 = [12 x i8] c"Hello world\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca [12 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 2
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @error(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %6
%19 = load i32, i32* %6
%20 = call i32 @startup(i32 %19)
store i32 %20, i32* %7
%21 = load i32, i32* %6
%22 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %7
%24 = call i32 @wait_client(i32 %23)
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8** %8
%25 = bitcast [12 x i8]* %9 to i8*
%26 = load i8*, i8** %8
%27 = getelementptr inbounds i8, i8* %26, i64 2
store i8 69, i8* %27
%28 = getelementptr inbounds [12 x i8], [12 x i8]* %9, i64 0, i64 2
store i8 69, i8* %28
%29 = load i8*, i8** %8
%30 = getelementptr inbounds i8, i8* %29, i64 2
store i8 69, i8* %30
%31 = getelementptr inbounds [12 x i8], [12 x i8]* %9, i64 0, i64 0
%32 = getelementptr inbounds i8, i8* %31, i64 2
store i8 69, i8* %32
ret i32 0
}

LLVM IR (-O2):
@.str = [42 x i8] c"\E8\AF\B7\E6\8C\87\E5\AE\9A\E7\AB\AF\E5\8F\A3\E5\8F\B7\0A\09Example: ./tiny 8000\0A\00"
@.str.1 = [23 x i8] c"listen on %d port ...\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @error(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = tail call i32 @startup(i32 %9)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%12 = tail call i32 @wait_client(i32 %10)
ret i32 0
}