#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 */
scalar_t__ ifdown(char *);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ tun_dealloc(int);
int StopTap(int sock, char *name) {
  if (ifdown(name) != 0) {
    printf("Failed to bring down interface %s\n", name);
    return -1;
  }
  if (tun_dealloc(sock) != 0) {
    printf("Failed to dealloc tap %s\n", name);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<StopTap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <ifdown@plt>
cmp    $0x0,%rax
je     116e <StopTap+0x3e>
mov    -0x10(%rbp),%rsi
lea    0xea3(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a3 <StopTap+0x73>
mov    -0x8(%rbp),%edi
call   1050 <tun_dealloc@plt>
cmp    $0x0,%rax
je     119c <StopTap+0x6c>
mov    -0x10(%rbp),%rsi
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a3 <StopTap+0x73>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<StopTap>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
call   1040 <ifdown@plt>
test   %rax,%rax
je     114e <StopTap+0x1e>
lea    0xeb4(%rip),%rdi
jmp    1161 <StopTap+0x31>
mov    %ebp,%edi
call   1050 <tun_dealloc@plt>
test   %rax,%rax
je     1175 <StopTap+0x45>
lea    0xec2(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %eax,%eax
jmp    116e <StopTap+0x3e>

LLVM IR (-O0):
@.str = [35 x i8] c"Failed to bring down interface %s\0A\00"
@.str.1 = [26 x i8] c"Failed to dealloc tap %s\0A\00"
define i32 @StopTap(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
%6 = load i8*, i8** %5
%7 = call i64 @ifdown(i8* %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i8*, i8** %5
%11 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %10)
store i32 -1, i32* %3
br label %20
12: ; preds = %2
%13 = load i32, i32* %4
%14 = call i64 @tun_dealloc(i32 %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %12
%17 = load i8*, i8** %5
%18 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %17)
store i32 -1, i32* %3
br label %20
19: ; preds = %12
store i32 0, i32* %3
br label %20
20: ; preds = %19, %16, %9
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
@.str = [35 x i8] c"Failed to bring down interface %s\0A\00"
@.str.1 = [26 x i8] c"Failed to dealloc tap %s\0A\00"
define i32 @StopTap(i32 %0, i8* %1) {
%3 = tail call i64 @ifdown(i8* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i64 @tun_dealloc(i32 %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %5, %2
%9 = phi i8* [ getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), %2 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), %5 ]
%10 = tail call i32 @printf(i8* %9, i8* %1)
br label %11
11: ; preds = %8, %5
%12 = phi i32 [ 0, %5 ], [ -1, %8 ]
ret i32 %12
}