#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*/ buf;

/* Variables and functions */
scalar_t__ call_svc(char *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int init_svc(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  char buf[1024];
  int done = 0;
  if (argc < 2) {
    printf("Usage: %s SOCKETFILE\n", argv[0]);
    return 1;
  }
  if (init_svc(argv[1]) == -1) {
    printf("Cannot get socket\n");
    return 1;
  }
  printf("Enter the hostname whose RRD cache should be flushed. One host per "
         "line\n");
  while (!done) {
    done = (fgets(buf, sizeof(buf), stdin) == NULL);
    if (done)
      continue;
    done = (call_svc(buf) != 0);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x414(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    118e <main+0x4e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    124d <main+0x10d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <init_svc@plt>
cmp    $0xffffffff,%eax
jne    11be <main+0x7e>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    124d <main+0x10d>
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x414(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    11e5 <main+0xa5>
jmp    1246 <main+0x106>
lea    -0x410(%rbp),%rdi
mov    0x2df5(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x414(%rbp)
cmpl   $0x0,-0x414(%rbp)
je     1223 <main+0xe3>
jmp    11cc <main+0x8c>
lea    -0x410(%rbp),%rdi
call   1050 <call_svc@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x414(%rbp)
jmp    11cc <main+0x8c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x400,%rsp
cmp    $0x1,%edi
jg     1173 <main+0x23>
mov    (%rsi),%rsi
lea    0xe96(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11d0 <main+0x80>
mov    0x8(%rsi),%rdi
call   1070 <init_svc@plt>
cmp    $0xffffffff,%eax
je     11c4 <main+0x74>
lea    0xe8e(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e54(%rip),%r14
mov    %rsp,%rbx
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    (%r14),%edx
mov    %rbx,%rdi
mov    $0x400,%esi
call   1050 <fgets@plt>
test   %rax,%rax
je     11d5 <main+0x85>
mov    %rbx,%rdi
call   1060 <call_svc@plt>
test   %rax,%rax
je     11a0 <main+0x50>
jmp    11d5 <main+0x85>
lea    0xe93(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Usage: %s SOCKETFILE\0A\00"
@.str.1 = [19 x i8] c"Cannot get socket\0A\00"
@.str.2 = [73 x i8] c"Enter the hostname whose RRD cache should be flushed. One host per line\0A\00"
@stdin = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 1, i32* %3
br label %44
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @init_svc(i8* %18)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %23
21: ; preds = %15
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %44
23: ; preds = %15
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.2, i64 0, i64 0))
br label %25
25: ; preds = %38, %37, %23
%26 = load i32, i32* %7
%27 = icmp ne i32 %26, 0
%28 = xor i1 %27, true
br i1 %28, label %29, label %43
29: ; preds = %25
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%31 = load i32, i32* @stdin
%32 = call i32* @fgets(i8* %30, i32 1024, i32 %31)
%33 = icmp eq i32* %32, null
%34 = zext i1 %33 to i32
store i32 %34, i32* %7
%35 = load i32, i32* %7
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %29
br label %25
38: ; preds = %29
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%40 = call i64 @call_svc(i8* %39)
%41 = icmp ne i64 %40, 0
%42 = zext i1 %41 to i32
store i32 %42, i32* %7
br label %25
43: ; preds = %25
store i32 0, i32* %3
br label %44
44: ; preds = %43, %21, %10
%45 = load i32, i32* %3
ret i32 %45
}

LLVM IR (-O2):
@.str = [22 x i8] c"Usage: %s SOCKETFILE\0A\00"
@stdin = global i32 0
@str = [72 x i8] c"Enter the hostname whose RRD cache should be flushed. One host per line\00"
@str.3 = [18 x i8] c"Cannot get socket\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %25
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @init_svc(i8* %11)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.3, i64 0, i64 0))
br label %25
16: ; preds = %9
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([72 x i8], [72 x i8]* @str, i64 0, i64 0))
br label %21
18: ; preds = %21
%19 = call i64 @call_svc(i8* %4)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %16, %18
%22 = load i32, i32* @stdin
%23 = call i32* @fgets(i8* %4, i32 1024, i32 %22)
%24 = icmp eq i32* %23, null
br i1 %24, label %25, label %18
25: ; preds = %21, %18, %14, %6
%26 = phi i32 [ 1, %6 ], [ 1, %14 ], [ 0, %18 ], [ 0, %21 ]
ret i32 %26
}