#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*/ pid_t;

/* Variables and functions */
int /*<<< orphan*/ execv(char *, char **);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ puts(char *);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ waitpid(int /*<<< orphan*/, int *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  char buffer[140];
  int i, j, status;
  char rew;
  char *args[4];
  pid_t pid;
  srand(time(NULL));
  while (1) {
    printf("mpainoume sth while\n");
    puts("arxid");
    for (j = 0; j < 140; j++) {
      rew = rand() % 27 + 97;
      buffer[j] = rew;
      printf("kai sth for\n");
    }
    buffer[140] = '\0';
    args[0] = "./twitsay";
    args[1] = "localhost";
    args[2] = "3331";
    args[3] = buffer;
    if ((pid = fork()) != 0) {
      waitpid(pid, &status, 0);
    } else {
      execv("./twitsay", args);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe50(%rip),%rdi
call   1040 <printf@plt>
lea    0xe59(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0xa8(%rbp)
cmpl   $0x8c,-0xa8(%rbp)
jge    1229 <main+0xa9>
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x1b,%ecx
cltd
idiv   %ecx
add    $0x61,%edx
mov    %dl,%al
mov    %al,-0xad(%rbp)
mov    -0xad(%rbp),%cl
movslq -0xa8(%rbp),%rax
mov    %cl,-0xa0(%rbp,%rax,1)
lea    0xe0b(%rip),%rdi
call   1040 <printf@plt>
mov    -0xa8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa8(%rbp)
jmp    11cb <main+0x4b>
movb   $0x0,-0x14(%rbp)
lea    0xdf4(%rip),%rax
mov    %rax,-0xd0(%rbp)
lea    0xdf0(%rip),%rax
mov    %rax,-0xc8(%rbp)
lea    0xdec(%rip),%rax
mov    %rax,-0xc0(%rbp)
lea    -0xa0(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    $0x0,%al
call   1090 <fork@plt>
mov    %eax,-0xd4(%rbp)
cmp    $0x0,%eax
je     1294 <main+0x114>
mov    -0xd4(%rbp),%edi
lea    -0xac(%rbp),%rsi
xor    %edx,%edx
call   1070 <waitpid@plt>
jmp    12a7 <main+0x127>
lea    -0xd0(%rbp),%rsi
lea    0xd86(%rip),%rdi
call   1080 <execv@plt>
jmp    11a9 <main+0x29>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc8,%rsp
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
lea    0xe9d(%rip),%rbx
lea    0xe69(%rip),%r12
lea    0xe6c(%rip),%r13
lea    0xe6f(%rip),%rbp
lea    0x30(%rsp),%r14
jmp    11ce <main+0x5e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %eax,%edi
lea    0xc(%rsp),%rsi
xor    %edx,%edx
call   1060 <waitpid@plt>
lea    0xe4a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe1f(%rip),%rdi
call   1030 <puts@plt>
xor    %r15d,%r15d
nopl   0x0(%rax)
xor    %eax,%eax
call   1090 <rand@plt>
cltq
imul   $0x4bda12f7,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,8),%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
add    $0x61,%al
mov    %al,0x30(%rsp,%r15,1)
mov    %rbx,%rdi
call   1030 <puts@plt>
add    $0x1,%r15
cmp    $0x8c,%r15
jne    11f0 <main+0x80>
movb   $0x0,0xbc(%rsp)
mov    %r12,0x10(%rsp)
mov    %r13,0x18(%rsp)
mov    %rbp,0x20(%rsp)
mov    %r14,0x28(%rsp)
xor    %eax,%eax
call   1080 <fork@plt>
test   %eax,%eax
jne    11c0 <main+0x50>
mov    %r12,%rdi
lea    0x10(%rsp),%rsi
call   1070 <execv@plt>
jmp    11ce <main+0x5e>

LLVM IR (-O0):
@.str = [21 x i8] c"mpainoume sth while\0A\00"
@.str.1 = [6 x i8] c"arxid\00"
@.str.2 = [13 x i8] c"kai sth for\0A\00"
@.str.3 = [10 x i8] c"./twitsay\00"
@.str.4 = [10 x i8] c"localhost\00"
@.str.5 = [5 x i8] c"3331\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [140 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8
%11 = alloca [4 x i8*]
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = call i32 @time(i32* null)
%14 = call i32 @srand(i32 %13)
br label %15
15: ; preds = %2, %49
%16 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %8
br label %18
18: ; preds = %31, %15
%19 = load i32, i32* %8
%20 = icmp slt i32 %19, 140
br i1 %20, label %21, label %34
21: ; preds = %18
%22 = call i32 (...) @rand()
%23 = srem i32 %22, 27
%24 = add nsw i32 %23, 97
%25 = trunc i32 %24 to i8
store i8 %25, i8* %10
%26 = load i8, i8* %10
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [140 x i8], [140 x i8]* %6, i64 0, i64 %28
store i8 %26, i8* %29
%30 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %31
31: ; preds = %21
%32 = load i32, i32* %8
%33 = add nsw i32 %32, 1
store i32 %33, i32* %8
br label %18
34: ; preds = %18
%35 = getelementptr inbounds [140 x i8], [140 x i8]* %6, i64 0, i64 140
store i8 0, i8* %35
%36 = getelementptr inbounds [4 x i8*], [4 x i8*]* %11, i64 0, i64 0
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %36
%37 = getelementptr inbounds [4 x i8*], [4 x i8*]* %11, i64 0, i64 1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8** %37
%38 = getelementptr inbounds [4 x i8*], [4 x i8*]* %11, i64 0, i64 2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %38
%39 = getelementptr inbounds [140 x i8], [140 x i8]* %6, i64 0, i64 0
%40 = getelementptr inbounds [4 x i8*], [4 x i8*]* %11, i64 0, i64 3
store i8* %39, i8** %40
%41 = call i32 (...) @fork()
store i32 %41, i32* %12
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %34
%44 = load i32, i32* %12
%45 = call i32 @waitpid(i32 %44, i32* %9, i32 0)
br label %49
46: ; preds = %34
%47 = getelementptr inbounds [4 x i8*], [4 x i8*]* %11, i64 0, i64 0
%48 = call i32 @execv(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %47)
br label %49
49: ; preds = %46, %43
br label %15
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"arxid\00"
@.str.3 = [10 x i8] c"./twitsay\00"
@.str.4 = [10 x i8] c"localhost\00"
@.str.5 = [5 x i8] c"3331\00"
@str = [20 x i8] c"mpainoume sth while\00"
@str.6 = [12 x i8] c"kai sth for\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [140 x i8]
%4 = alloca i32
%5 = alloca [4 x i8*]
%6 = getelementptr inbounds [140 x i8], [140 x i8]* %3, i64 0, i64 0
%7 = bitcast i32* %4 to i8*
%8 = bitcast [4 x i8*]* %5 to i8*
%9 = tail call i32 @time(i32* null)
%10 = tail call i32 @srand(i32 %9)
%11 = getelementptr inbounds [140 x i8], [140 x i8]* %3, i64 0, i64 140
%12 = getelementptr inbounds [4 x i8*], [4 x i8*]* %5, i64 0, i64 0
%13 = getelementptr inbounds [4 x i8*], [4 x i8*]* %5, i64 0, i64 1
%14 = getelementptr inbounds [4 x i8*], [4 x i8*]* %5, i64 0, i64 2
%15 = getelementptr inbounds [4 x i8*], [4 x i8*]* %5, i64 0, i64 3
br label %16
16: ; preds = %36, %2
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %16, %19
%20 = phi i64 [ 0, %16 ], [ %27, %19 ]
%21 = call i32 (...) @rand()
%22 = srem i32 %21, 27
%23 = trunc i32 %22 to i8
%24 = add nsw i8 %23, 97
%25 = getelementptr inbounds [140 x i8], [140 x i8]* %3, i64 0, i64 %20
store i8 %24, i8* %25
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.6, i64 0, i64 0))
%27 = add nuw nsw i64 %20, 1
%28 = icmp eq i64 %27, 140
br i1 %28, label %29, label %19
29: ; preds = %19
store i8 0, i8* %11
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %12
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8** %13
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8** %14
store i8* %6, i8** %15
%30 = call i32 (...) @fork()
%31 = icmp eq i32 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %29
%33 = call i32 @waitpid(i32 %30, i32* %4, i32 0)
br label %36
34: ; preds = %29
%35 = call i32 @execv(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %12)
br label %36
36: ; preds = %34, %32
br label %16
}