#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) {
    int r = read(in, &x, len);
    if (r <= 0) {
      break;
    } else if (r != 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>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jg     1177 <fils+0x37>
jmp    11c5 <fils+0x85>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     1188 <fils+0x48>
jmp    1156 <fils+0x16>
jmp    118d <fils+0x4d>
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    0xe54(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x0,-0x10(%rbp)
jne    11c0 <fils+0x80>
jmp    11c5 <fils+0x85>
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),%rsi
mov    %ebx,%edi
mov    $0x4,%edx
call   1050 <read@plt>
test   %eax,%eax
jle    11b6 <fils+0x76>
lea    0xe93(%rip),%r15
lea    0xc(%rsp),%r12
jmp    1193 <fils+0x53>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,%edi
mov    %r12,%rsi
mov    $0x4,%edx
call   1050 <read@plt>
test   %eax,%eax
jle    11b6 <fils+0x76>
cmp    $0x4,%eax
jne    1180 <fils+0x40>
xor    %eax,%eax
call   1030 <getpid@plt>
mov    0xc(%rsp),%ebp
mov    %r15,%rdi
mov    %r14,%rsi
mov    %eax,%edx
mov    %ebp,%ecx
call   1040 <printf@plt>
test   %ebp,%ebp
jne    1180 <fils+0x40>
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
%7 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 4, i32* %6
br label %8
8: ; preds = %2, %19, %29
%9 = load i32, i32* %4
%10 = load i32, i32* %6
%11 = call i32 @read(i32 %9, i32* %5, i32 %10)
store i32 %11, i32* %7
%12 = load i32, i32* %7
%13 = icmp sle i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %8
br label %30
15: ; preds = %8
%16 = load i32, i32* %7
%17 = load i32, i32* %6
%18 = icmp ne i32 %16, %17
br i1 %18, label %19, label %20
19: ; preds = %15
br label %8
20: ; preds = %15
br label %21
21: ; preds = %20
%22 = load i8*, i8** %3
%23 = call i32 (...) @getpid()
%24 = load i32, i32* %5
%25 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %22, i32 %23, i32 %24)
%26 = load i32, i32* %5
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %21
br label %30
29: ; preds = %21
br label %8
30: ; preds = %28, %14
%31 = 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*
%5 = call i32 @read(i32 %1, i32* %3, i32 4)
%6 = icmp slt i32 %5, 1
br i1 %6, label %18, label %7
7: ; preds = %2, %15
%8 = phi i32 [ %16, %15 ], [ %5, %2 ]
%9 = icmp eq i32 %8, 4
br i1 %9, label %10, label %15
10: ; preds = %7
%11 = tail call i32 (...) @getpid()
%12 = load i32, i32* %3
%13 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %11, i32 %12)
%14 = icmp eq i32 %12, 0
br i1 %14, label %18, label %15
15: ; preds = %10, %7
%16 = call i32 @read(i32 %1, i32* %3, i32 4)
%17 = icmp slt i32 %16, 1
br i1 %17, label %18, label %7
18: ; preds = %15, %10, %2
%19 = tail call i32 @exit(i32 0)
unreachable
}