#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 /*<<< orphan*/ O_WRONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char *getenv(char *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int, char *);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ write(int, char *, scalar_t__);
int main(int argc, char *argv[]) {
  FILE *client_fifo;
  char *home = getenv("HOME");
  char msg[200] = "";
  char information[120] = "";
  char buffer[80] = "";
  int index = 0;
  int server_fifo = open("/home/pdziegielewski/serwerfifo", O_WRONLY);
  strcat(information, argv[1]);
  strcat(information, home);
  do {
    index = index + 1;
  } while (information[index] != '\0');
  sprintf(msg, "%d%s", index, information);
  write(server_fifo, msg, strlen(msg) + 1);
  close(server_fifo);
  client_fifo = fopen("/home/pdziegielewski/klientfifo", "r");
  fgets(buffer, 80, client_fifo);
  printf("%s\n", buffer);
  fclose(client_fifo);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1e0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe20(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x20(%rbp)
lea    -0xf0(%rbp),%rdi
xor    %esi,%esi
mov    $0xc8,%edx
call   1080 <memset@plt>
lea    -0x170(%rbp),%rdi
xor    %esi,%esi
mov    $0x78,%edx
call   1080 <memset@plt>
lea    -0x1c0(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1080 <memset@plt>
movl   $0x0,-0x1c4(%rbp)
mov    0x2da5(%rip),%rax
mov    (%rax),%esi
lea    0xdc9(%rip),%rdi
call   10b0 <open@plt>
mov    %eax,-0x1c8(%rbp)
lea    -0x170(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   10d0 <strcat@plt>
lea    -0x170(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   10d0 <strcat@plt>
mov    -0x1c4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c4(%rbp)
movslq -0x1c4(%rbp),%rax
movsbl -0x170(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
jne    126b <main+0xab>
lea    -0xf0(%rbp),%rdi
mov    -0x1c4(%rbp),%edx
lea    -0x170(%rbp),%rcx
lea    0xd78(%rip),%rsi
call   10e0 <sprintf@plt>
mov    -0x1c8(%rbp),%eax
mov    %eax,-0x1d4(%rbp)
lea    -0xf0(%rbp),%rax
mov    %rax,-0x1d0(%rbp)
lea    -0xf0(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x1d4(%rbp),%edi
mov    -0x1d0(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1040 <write@plt>
mov    -0x1c8(%rbp),%edi
call   1090 <close@plt>
lea    0xd27(%rip),%rdi
lea    0xd40(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
lea    -0x1c0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x50,%esi
call   10a0 <fgets@plt>
lea    -0x1c0(%rbp),%rsi
lea    0xd16(%rip),%rdi
call   1070 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x1e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x198,%rsp
mov    %rsi,%r15
lea    0xe39(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%r14
xorps  %xmm0,%xmm0
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)
movq   $0x0,0x190(%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)
movq   $0x0,0x70(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
mov    0x2d40(%rip),%rax
mov    (%rax),%esi
lea    0xd64(%rip),%rdi
call   10a0 <open@plt>
mov    %eax,%ebp
mov    0x8(%r15),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   10c0 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10c0 <strcat@plt>
xor    %edx,%edx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmpb   $0x0,0x1(%rsp,%rdx,1)
lea    0x1(%rdx),%rdx
jne    12d0 <main+0x120>
lea    0xd43(%rip),%rsi
lea    0xd0(%rsp),%rbx
mov    %rsp,%rcx
mov    %rbx,%rdi
call   10d0 <sprintf@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1040 <write@plt>
mov    %ebp,%edi
call   1080 <close@plt>
lea    0xd11(%rip),%rdi
lea    0xd2a(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,%rbx
lea    0x80(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x50,%esi
mov    %rax,%rdx
call   1090 <fgets@plt>
lea    0xd05(%rip),%rdi
mov    %rbp,%rsi
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x198,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [32 x i8] c"/home/pdziegielewski/serwerfifo\00"
@O_WRONLY = global i32 0
@.str.2 = [5 x i8] c"%d%s\00"
@.str.3 = [32 x i8] c"/home/pdziegielewski/klientfifo\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca [200 x i8]
%9 = alloca [120 x i8]
%10 = alloca [80 x i8]
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %13, i8** %7
%14 = bitcast [200 x i8]* %8 to i8*
%15 = bitcast [120 x i8]* %9 to i8*
%16 = bitcast [80 x i8]* %10 to i8*
store i32 0, i32* %11
%17 = load i32, i32* @O_WRONLY
%18 = call i32 @open(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %17)
store i32 %18, i32* %12
%19 = getelementptr inbounds [120 x i8], [120 x i8]* %9, i64 0, i64 0
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @strcat(i8* %19, i8* %22)
%24 = getelementptr inbounds [120 x i8], [120 x i8]* %9, i64 0, i64 0
%25 = load i8*, i8** %7
%26 = call i32 @strcat(i8* %24, i8* %25)
br label %27
27: ; preds = %30, %2
%28 = load i32, i32* %11
%29 = add nsw i32 %28, 1
store i32 %29, i32* %11
br label %30
30: ; preds = %27
%31 = load i32, i32* %11
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [120 x i8], [120 x i8]* %9, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp ne i32 %35, 0
br i1 %36, label %27, label %37
37: ; preds = %30
%38 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 0
%39 = load i32, i32* %11
%40 = getelementptr inbounds [120 x i8], [120 x i8]* %9, i64 0, i64 0
%41 = call i32 @sprintf(i8* %38, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %39, i8* %40)
%42 = load i32, i32* %12
%43 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 0
%44 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 0
%45 = call i64 @strlen(i8* %44)
%46 = add nsw i64 %45, 1
%47 = call i32 @write(i32 %42, i8* %43, i64 %46)
%48 = load i32, i32* %12
%49 = call i32 @close(i32 %48)
%50 = call i32* @fopen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %50, i32** %6
%51 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%52 = load i32*, i32** %6
%53 = call i32 @fgets(i8* %51, i32 80, i32* %52)
%54 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%55 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %54)
%56 = load i32*, i32** %6
%57 = call i32 @fclose(i32* %56)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"HOME\00"
@.str.1 = [32 x i8] c"/home/pdziegielewski/serwerfifo\00"
@O_WRONLY = global i32 0
@.str.2 = [5 x i8] c"%d%s\00"
@.str.3 = [32 x i8] c"/home/pdziegielewski/klientfifo\00"
@.str.4 = [2 x i8] c"r\00"
@.str.5 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [200 x i8]
%4 = alloca [120 x i8]
%5 = alloca [80 x i8]
%6 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [120 x i8], [120 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%10 = load i32, i32* @O_WRONLY
%11 = tail call i32 @open(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @strcat(i8* %8, i8* %13)
%15 = call i32 @strcat(i8* %8, i8* %6)
br label %16
16: ; preds = %16, %2
%17 = phi i64 [ %18, %16 ], [ 0, %2 ]
%18 = add nuw nsw i64 %17, 1
%19 = getelementptr inbounds [120 x i8], [120 x i8]* %4, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %22, label %16
22: ; preds = %16
%23 = trunc i64 %18 to i32
%24 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %23, i8* %8)
%25 = call i64 @strlen(i8* %7)
%26 = add nsw i64 %25, 1
%27 = call i32 @write(i32 %11, i8* %7, i64 %26)
%28 = call i32 @close(i32 %11)
%29 = call i32* @fopen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%30 = call i32 @fgets(i8* %9, i32 80, i32* %29)
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %9)
%32 = call i32 @fclose(i32* %29)
ret i32 0
}