#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *open_socket(char *, char *);
int /*<<< orphan*/ place_metadata_request(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ read_and_print_metadata(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  FILE *sock = open_socket("localhost", "9092");
  printf("CLUSTER METADATA:\n\n");
  place_metadata_request(sock);
  read_and_print_metadata(sock);
  fclose(sock);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe93(%rip),%rdi
lea    0xe96(%rip),%rsi
call   1040 <open_socket@plt>
mov    %rax,-0x18(%rbp)
lea    0xe8b(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1070 <place_metadata_request@plt>
mov    -0x18(%rbp),%rdi
call   1060 <read_and_print_metadata@plt>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xea8(%rip),%rdi
lea    0xeab(%rip),%rsi
call   1050 <open_socket@plt>
mov    %rax,%rbx
lea    0xea1(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1070 <place_metadata_request@plt>
mov    %rbx,%rdi
call   1060 <read_and_print_metadata@plt>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"localhost\00"
@.str.1 = [5 x i8] c"9092\00"
@.str.2 = [20 x i8] c"CLUSTER METADATA:\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32* @open_socket(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %6
%8 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%9 = load i32*, i32** %6
%10 = call i32 @place_metadata_request(i32* %9)
%11 = load i32*, i32** %6
%12 = call i32 @read_and_print_metadata(i32* %11)
%13 = load i32*, i32** %6
%14 = call i32 @fclose(i32* %13)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"localhost\00"
@.str.1 = [5 x i8] c"9092\00"
@str = [19 x i8] c"CLUSTER METADATA:\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32* @open_socket(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 @place_metadata_request(i32* %3)
%6 = tail call i32 @read_and_print_metadata(i32* %3)
%7 = tail call i32 @fclose(i32* %3)
ret i32 0
}