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

/* Variables and functions */
int O_APPEND;
int O_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int isServerDone();
int /*<<< orphan*/ lockfileCheck();
int open(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ remove(char *);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ write(int, char *, int);
int main(int argc, char *argv[]) {
  lockfileCheck();
  FILE *clear_data = fopen("dane.txt", "w");
  fclose(clear_data);
  char msg[256] = "";
  char reply[256] = "";
  FILE *konto = fopen("dane.txt", "w");
  fprintf(konto, "%s", argv[1]);
  fprintf(konto, "\n");
  fclose(konto);
  scanf("%[^/\x1b]s", msg);
  int data_file = open("dane.txt", O_WRONLY | O_APPEND);
  write(data_file, msg, 256);
  close(data_file);
  FILE *done = fopen("done", "w");
  fprintf(done, "done");
  fclose(done);
  sleep(10);
  printf("przed ifem\n");
  while (1) {
    int b = isServerDone();
    if (b == 1) {
      break;
    }
  }
  remove("done");
  FILE *result_file = fopen("wyniki.txt", "r");
  while (fgets(reply, 256, result_file) != NULL) {
    printf("%s", reply);
  }
  printf("\n");
  fclose(result_file);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <lockfileCheck@plt>
lea    0xdf9(%rip),%rdi
lea    0xdfb(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <fclose@plt>
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1080 <memset@plt>
lea    -0x220(%rbp),%rdi
xor    %esi,%esi
mov    $0x100,%edx
call   1080 <memset@plt>
lea    0xdb3(%rip),%rdi
lea    0xdb5(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x228(%rbp)
mov    -0x228(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd95(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x228(%rbp),%rdi
lea    0xd9a(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x228(%rbp),%rdi
call   1060 <fclose@plt>
lea    -0x120(%rbp),%rsi
lea    0xd62(%rip),%rdi
call   10d0 <scanf@plt>
mov    0x2d20(%rip),%rax
mov    (%rax),%esi
mov    0x2d0f(%rip),%rax
or     (%rax),%esi
lea    0xd36(%rip),%rdi
call   10e0 <open@plt>
mov    %eax,-0x22c(%rbp)
mov    -0x22c(%rbp),%edi
lea    -0x120(%rbp),%rsi
mov    $0x100,%edx
call   1050 <write@plt>
mov    -0x22c(%rbp),%edi
call   1090 <close@plt>
lea    0xd18(%rip),%rdi
lea    0xd04(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x238(%rbp)
mov    -0x238(%rbp),%rdi
lea    0xcf7(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    -0x238(%rbp),%rdi
call   1060 <fclose@plt>
mov    $0xa,%edi
call   1100 <sleep@plt>
lea    0xcd8(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    $0x0,%al
call   10b0 <isServerDone@plt>
mov    %eax,-0x23c(%rbp)
cmpl   $0x1,-0x23c(%rbp)
jne    1369 <main+0x189>
jmp    136e <main+0x18e>
jmp    134a <main+0x16a>
lea    0xca1(%rip),%rdi
call   1040 <remove@plt>
lea    0xca6(%rip),%rdi
lea    0xcaa(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x248(%rbp)
lea    -0x220(%rbp),%rdi
mov    -0x248(%rbp),%rdx
mov    $0x100,%esi
call   10a0 <fgets@plt>
cmp    $0x0,%rax
je     13d0 <main+0x1f0>
lea    -0x220(%rbp),%rsi
lea    0xc47(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1394 <main+0x1b4>
lea    0xc4e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x248(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x200,%rsp
mov    %rsi,%r12
xor    %eax,%eax
call   1030 <lockfileCheck@plt>
lea    0xdd0(%rip),%r15
lea    0xdd2(%rip),%r14
mov    %r15,%rdi
mov    %r14,%rsi
call   1110 <fopen@plt>
mov    %rax,%rdi
call   1080 <fclose@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x1f0(%rsp)
movaps %xmm0,0x1e0(%rsp)
movaps %xmm0,0x1d0(%rsp)
movaps %xmm0,0x1c0(%rsp)
movaps %xmm0,0x1b0(%rsp)
movaps %xmm0,0x1a0(%rsp)
movaps %xmm0,0x190(%rsp)
movaps %xmm0,0x180(%rsp)
movaps %xmm0,0x170(%rsp)
movaps %xmm0,0x160(%rsp)
movaps %xmm0,0x150(%rsp)
movaps %xmm0,0x140(%rsp)
movaps %xmm0,0x130(%rsp)
movaps %xmm0,0x120(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xf0(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    %r15,%rdi
mov    %r14,%rsi
call   1110 <fopen@plt>
mov    %rax,%rbx
mov    0x8(%r12),%rdi
mov    %rax,%rsi
call   10a0 <fputs@plt>
mov    $0xa,%edi
mov    %rbx,%rsi
call   10c0 <fputc@plt>
mov    %rbx,%rdi
call   1080 <fclose@plt>
lea    0xca3(%rip),%rdi
lea    0x100(%rsp),%rbx
mov    %rbx,%rsi
call   10f0 <scanf@plt>
mov    0x2c56(%rip),%rax
mov    0x2c47(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %r15,%rdi
call   1100 <open@plt>
mov    %eax,%ebp
mov    %eax,%edi
mov    %rbx,%rsi
mov    $0x100,%edx
call   1070 <write@plt>
mov    %ebp,%edi
call   10b0 <close@plt>
lea    0xc62(%rip),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1110 <fopen@plt>
mov    %rax,%rbp
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rdi
mov    %rax,%rcx
call   1120 <fwrite@plt>
mov    %rbp,%rdi
call   1080 <fclose@plt>
mov    $0xa,%edi
call   1130 <sleep@plt>
lea    0xc38(%rip),%rdi
call   1060 <puts@plt>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   10e0 <isServerDone@plt>
cmp    $0x1,%eax
jne    1400 <main+0x1f0>
lea    0xc03(%rip),%rdi
call   1050 <remove@plt>
lea    0xbfc(%rip),%rdi
lea    0xc00(%rip),%rsi
call   1110 <fopen@plt>
mov    %rax,%r15
mov    %rsp,%rdi
mov    $0x100,%esi
mov    %rax,%rdx
call   10d0 <fgets@plt>
test   %rax,%rax
je     1472 <main+0x262>
lea    0xbc1(%rip),%r14
mov    %rsp,%rbx
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <printf@plt>
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r15,%rdx
call   10d0 <fgets@plt>
test   %rax,%rax
jne    1450 <main+0x240>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r15,%rdi
call   1080 <fclose@plt>
xor    %eax,%eax
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"dane.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [8 x i8] c"%[^/\1B]s\00"
@O_WRONLY = global i32 0
@O_APPEND = global i32 0
@.str.5 = [5 x i8] c"done\00"
@.str.6 = [12 x i8] c"przed ifem\0A\00"
@.str.7 = [11 x i8] c"wyniki.txt\00"
@.str.8 = [2 x i8] c"r\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [256 x i8]
%8 = alloca [256 x i8]
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32
%13 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = call i32 (...) @lockfileCheck()
%15 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %15, i32** %6
%16 = load i32*, i32** %6
%17 = call i32 @fclose(i32* %16)
%18 = bitcast [256 x i8]* %7 to i8*
%19 = bitcast [256 x i8]* %8 to i8*
%20 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %9
%21 = load i32*, i32** %9
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %24)
%26 = load i32*, i32** %9
%27 = call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%28 = load i32*, i32** %9
%29 = call i32 @fclose(i32* %28)
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%31 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %30)
%32 = load i32, i32* @O_WRONLY
%33 = load i32, i32* @O_APPEND
%34 = or i32 %32, %33
%35 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %34)
store i32 %35, i32* %10
%36 = load i32, i32* %10
%37 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%38 = call i32 @write(i32 %36, i8* %37, i32 256)
%39 = load i32, i32* %10
%40 = call i32 @close(i32 %39)
%41 = call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %41, i32** %11
%42 = load i32*, i32** %11
%43 = call i32 (i32*, i8*, ...) @fprintf(i32* %42, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%44 = load i32*, i32** %11
%45 = call i32 @fclose(i32* %44)
%46 = call i32 @sleep(i32 10)
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
br label %48
48: ; preds = %2, %53
%49 = call i32 (...) @isServerDone()
store i32 %49, i32* %12
%50 = load i32, i32* %12
%51 = icmp eq i32 %50, 1
br i1 %51, label %52, label %53
52: ; preds = %48
br label %54
53: ; preds = %48
br label %48
54: ; preds = %52
%55 = call i32 @remove(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%56 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i32* %56, i32** %13
br label %57
57: ; preds = %62, %54
%58 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%59 = load i32*, i32** %13
%60 = call i32* @fgets(i8* %58, i32 256, i32* %59)
%61 = icmp ne i32* %60, null
br i1 %61, label %62, label %65
62: ; preds = %57
%63 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %63)
br label %57
65: ; preds = %57
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%67 = load i32*, i32** %13
%68 = call i32 @fclose(i32* %67)
%69 = load i32, i32* %3
ret i32 %69
}

LLVM IR (-O2):
@.str = [9 x i8] c"dane.txt\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [3 x i8] c"%s\00"
@.str.4 = [8 x i8] c"%[^/\1B]s\00"
@O_WRONLY = global i32 0
@O_APPEND = global i32 0
@.str.5 = [5 x i8] c"done\00"
@.str.7 = [11 x i8] c"wyniki.txt\00"
@.str.8 = [2 x i8] c"r\00"
@str = [11 x i8] c"przed ifem\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca [256 x i8]
%5 = tail call i32 (...) @lockfileCheck()
%6 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @fclose(i32* %6)
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%10 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @fputs(i8* %12, i32* %10)
%14 = tail call i32 @fputc(i32 10, i32* %10)
%15 = tail call i32 @fclose(i32* %10)
%16 = call i32 @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %8)
%17 = load i32, i32* @O_WRONLY
%18 = load i32, i32* @O_APPEND
%19 = or i32 %18, %17
%20 = call i32 @open(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = call i32 @write(i32 %20, i8* %8, i32 256)
%22 = call i32 @close(i32 %20)
%23 = call i32* @fopen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%24 = call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i64 4, i64 1, i32* %23)
%25 = call i32 @fclose(i32* %23)
%26 = call i32 @sleep(i32 10)
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
br label %28
28: ; preds = %28, %2
%29 = call i32 (...) @isServerDone()
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %28
31: ; preds = %28
%32 = call i32 @remove(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%33 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%34 = call i32* @fgets(i8* %9, i32 256, i32* %33)
%35 = icmp eq i32* %34, null
br i1 %35, label %40, label %36
36: ; preds = %31, %36
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%38 = call i32* @fgets(i8* %9, i32 256, i32* %33)
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %36
40: ; preds = %36, %31
%41 = call i32 @putchar(i32 10)
%42 = call i32 @fclose(i32* %33)
ret i32 0
}