#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 EXIT_SUCCESS;
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ perror(char *);
int read(int, char *, int);
int recv_message(int *sock, char *buffer) {
  bzero(buffer, 100);
  int count = read(*sock, buffer, 100);
  if (count < 0) {
    perror("Receiving message");
    return 7;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<recv_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x64,%esi
call   1050 <bzero@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
mov    $0x64,%edx
call   1030 <read@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    1187 <recv_message+0x57>
lea    0xe8a(%rip),%rdi
call   1040 <perror@plt>
movl   $0x7,-0x4(%rbp)
jmp    1193 <recv_message+0x63>
mov    0x2e52(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recv_message>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
mov    $0x64,%esi
call   1050 <bzero@plt>
mov    (%r14),%edi
mov    %rbx,%rsi
mov    $0x64,%edx
call   1030 <read@plt>
test   %eax,%eax
js     116c <recv_message+0x3c>
mov    0x2e7e(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe8d(%rip),%rdi
call   1040 <perror@plt>
mov    $0x7,%eax
jmp    1164 <recv_message+0x34>

LLVM IR (-O0):
@.str = [18 x i8] c"Receiving message\00"
@EXIT_SUCCESS = global i32 0
define i32 @recv_message(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = call i32 @bzero(i8* %7, i32 100)
%9 = load i32*, i32** %4
%10 = load i32, i32* %9
%11 = load i8*, i8** %5
%12 = call i32 @read(i32 %10, i8* %11, i32 100)
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 7, i32* %3
br label %19
17: ; preds = %2
%18 = load i32, i32* @EXIT_SUCCESS
store i32 %18, i32* %3
br label %19
19: ; preds = %17, %15
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
@.str = [18 x i8] c"Receiving message\00"
@EXIT_SUCCESS = global i32 0
define i32 @recv_message(i32* nocapture %0, i8* nocapture %1) {
%3 = tail call i32 @bzero(i8* %1, i32 100)
%4 = load i32, i32* %0
%5 = tail call i32 @read(i32 %4, i8* %1, i32 100)
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %11
9: ; preds = %2
%10 = load i32, i32* @EXIT_SUCCESS
br label %11
11: ; preds = %9, %7
%12 = phi i32 [ 7, %7 ], [ %10, %9 ]
ret i32 %12
}