#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*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char const *);
char *recv_msg(char *, int);
void recv_ack() {
  char buf[80];
  const char *reply;
  memset(buf, 0, 80);
  reply = recv_msg(buf, 80);
  while (reply && reply[0] != '.') {
    printf("Unexpected reply: >>%s<<\n", reply);
    reply = recv_msg(buf, 80);
  }
}


x86 assembly (clang, -O0):
<recv_ack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1050 <memset@plt>
lea    -0x50(%rbp),%rdi
mov    $0x50,%esi
call   1030 <recv_msg@plt>
mov    %rax,-0x58(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x58(%rbp)
mov    %al,-0x59(%rbp)
je     117a <recv_ack+0x4a>
mov    -0x58(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
setne  %al
mov    %al,-0x59(%rbp)
mov    -0x59(%rbp),%al
test   $0x1,%al
jne    118a <recv_ack+0x5a>
jmp    11b1 <recv_ack+0x81>
mov    -0x58(%rbp),%rsi
lea    0xe6b(%rip),%rdi
call   1040 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    $0x50,%esi
call   1030 <recv_msg@plt>
mov    %rax,-0x58(%rbp)
jmp    115a <recv_ack+0x2a>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recv_ack>:
push   %r14
push   %rbx
sub    $0x58,%rsp
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
mov    $0x50,%esi
call   1030 <recv_msg@plt>
test   %rax,%rax
je     1192 <recv_ack+0x62>
lea    0xe9e(%rip),%r14
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
cmpb   $0x2e,(%rax)
je     1192 <recv_ack+0x62>
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x50,%esi
call   1030 <recv_msg@plt>
test   %rax,%rax
jne    1170 <recv_ack+0x40>
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Unexpected reply: >>%s<<\0A\00"
define void @recv_ack() {
%1 = alloca [80 x i8]
%2 = alloca i8*
%3 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%4 = call i32 @memset(i8* %3, i32 0, i32 80)
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%6 = call i8* @recv_msg(i8* %5, i32 80)
store i8* %6, i8** %2
br label %7
7: ; preds = %18, %0
%8 = load i8*, i8** %2
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = load i8*, i8** %2
%12 = getelementptr inbounds i8, i8* %11, i64 0
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 46
br label %16
16: ; preds = %10, %7
%17 = phi i1 [ false, %7 ], [ %15, %10 ]
br i1 %17, label %18, label %23
18: ; preds = %16
%19 = load i8*, i8** %2
%20 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%22 = call i8* @recv_msg(i8* %21, i32 80)
store i8* %22, i8** %2
br label %7
23: ; preds = %16
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"Unexpected reply: >>%s<<\0A\00"
define void @recv_ack() {
%1 = alloca [80 x i8]
%2 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%3 = call i32 @memset(i8* %2, i32 0, i32 80)
%4 = call i8* @recv_msg(i8* %2, i32 80)
%5 = icmp eq i8* %4, null
br i1 %5, label %14, label %6
6: ; preds = %0, %10
%7 = phi i8* [ %12, %10 ], [ %4, %0 ]
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 46
br i1 %9, label %14, label %10
10: ; preds = %6
%11 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %7)
%12 = call i8* @recv_msg(i8* %2, i32 80)
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %6
14: ; preds = %6, %10, %0
ret void
}