#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 intercomm_stop();
int /*<<< orphan*/ printf(char *, ...);
int stopasf();
int closedown() {
  int err;
  err = stopasf();
  if (err) {
    printf("stopasf failed (err=%i)\n", err);
    return err;
  }
  err = intercomm_stop();
  if (err) {
    printf("intercomm_stop failed (err=%i)\n", err);
    return err;
  }
  printf("closedown done\n");
  return err;
}


x86 assembly (clang, -O0):
<closedown>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <stopasf@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1168 <closedown+0x38>
mov    -0x8(%rbp),%esi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ac <closedown+0x7c>
mov    $0x0,%al
call   1050 <intercomm_stop@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1198 <closedown+0x68>
mov    -0x8(%rbp),%esi
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ac <closedown+0x7c>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<closedown>:
push   %rbp
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <stopasf@plt>
test   %eax,%eax
je     1162 <closedown+0x22>
mov    %eax,%ebx
lea    0xea9(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1191 <closedown+0x51>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <intercomm_stop@plt>
test   %eax,%eax
je     1185 <closedown+0x45>
mov    %eax,%ebp
lea    0xea1(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%ebx
jmp    1191 <closedown+0x51>
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"stopasf failed (err=%i)\0A\00"
@.str.1 = [32 x i8] c"intercomm_stop failed (err=%i)\0A\00"
@.str.2 = [16 x i8] c"closedown done\0A\00"
define i32 @closedown() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @stopasf()
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp ne i32 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = load i32, i32* %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %2
store i32 %9, i32* %1
br label %21
10: ; preds = %0
%11 = call i32 (...) @intercomm_stop()
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i32, i32* %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %2
store i32 %17, i32* %1
br label %21
18: ; preds = %10
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%20 = load i32, i32* %2
store i32 %20, i32* %1
br label %21
21: ; preds = %18, %14, %6
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@.str = [25 x i8] c"stopasf failed (err=%i)\0A\00"
@.str.1 = [32 x i8] c"intercomm_stop failed (err=%i)\0A\00"
@str = [15 x i8] c"closedown done\00"
define i32 @closedown() {
%1 = tail call i32 (...) @stopasf()
%2 = icmp eq i32 %1, 0
br i1 %2, label %5, label %3
3: ; preds = %0
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %12
5: ; preds = %0
%6 = tail call i32 (...) @intercomm_stop()
%7 = icmp eq i32 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %6)
br label %12
10: ; preds = %5
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %10, %8, %3
%13 = phi i32 [ %1, %3 ], [ %6, %8 ], [ 0, %10 ]
ret i32 %13
}