#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 /*<<< orphan*/ exit(int /*<<< orphan*/);
int getpid();
int /*<<< orphan*/ printf(char *, char *, int, int);
int read(int, int *, int);
void fils(char *nickname, int in) {
  int x;
  int len = sizeof x;
  while (1) {
    if (read(in, &x, len) != len)
      continue;
    printf("%s:%d: %d\n", nickname, getpid(), x);
    if (x == 0)
      break;
  }
  exit(0);
}


x86 assembly (clang, -O0):
<fils>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x4,-0x14(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x14(%rbp),%edx
lea    -0x10(%rbp),%rsi
call   1050 <read@plt>
cmp    -0x14(%rbp),%eax
je     1173 <fils+0x33>
jmp    1156 <fils+0x16>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
mov    -0x10(%rbp),%ecx
lea    0xe6e(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,-0x10(%rbp)
jne    11a6 <fils+0x66>
jmp    11ab <fils+0x6b>
jmp    1156 <fils+0x16>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<fils>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
mov    %rdi,%r14
lea    0xc(%rsp),%r15
lea    0xea3(%rip),%r12
nopl   (%rax)
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x4,%edx
call   1050 <read@plt>
cmp    $0x4,%eax
jne    1160 <fils+0x20>
xor    %eax,%eax
call   1030 <getpid@plt>
mov    0xc(%rsp),%ebp
mov    %r12,%rdi
mov    %r14,%rsi
mov    %eax,%edx
mov    %ebp,%ecx
call   1040 <printf@plt>
test   %ebp,%ebp
jne    1160 <fils+0x20>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"%s:%d: %d\0A\00"
define void @fils(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 4, i32* %6
br label %7
7: ; preds = %2, %13, %22
%8 = load i32, i32* %4
%9 = load i32, i32* %6
%10 = call i32 @read(i32 %8, i32* %5, i32 %9)
%11 = load i32, i32* %6
%12 = icmp ne i32 %10, %11
br i1 %12, label %13, label %14
13: ; preds = %7
br label %7
14: ; preds = %7
%15 = load i8*, i8** %3
%16 = call i32 (...) @getpid()
%17 = load i32, i32* %5
%18 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %15, i32 %16, i32 %17)
%19 = load i32, i32* %5
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %14
br label %23
22: ; preds = %14
br label %7
23: ; preds = %21
%24 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [11 x i8] c"%s:%d: %d\0A\00"
define void @fils(i8* %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
br label %5
5: ; preds = %8, %2
%6 = call i32 @read(i32 %1, i32* %3, i32 4)
%7 = icmp eq i32 %6, 4
br i1 %7, label %9, label %8
8: ; preds = %5, %9
br label %5
9: ; preds = %5
%10 = tail call i32 (...) @getpid()
%11 = load i32, i32* %3
%12 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %10, i32 %11)
%13 = icmp eq i32 %11, 0
br i1 %13, label %14, label %8
14: ; preds = %9
%15 = tail call i32 @exit(i32 0)
unreachable
}