#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ O_NONBLOCK;
int /*<<< orphan*/ __NR_delete_module;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ puts(char *);
scalar_t__ syscall(int /*<<< orphan*/, char *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  if (argc != 2) {
    puts("Usage ./prog mymodule");
    return EXIT_FAILURE;
  }
  if (syscall(__NR_delete_module, argv[1], O_NONBLOCK) != 0) {
    perror("delete_module");
    return EXIT_FAILURE;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     116d <main+0x3d>
lea    0xea9(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11bf <main+0x8f>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    0x2e63(%rip),%rax
mov    (%rax),%edx
call   1040 <syscall@plt>
cmp    $0x0,%rax
je     11b3 <main+0x83>
lea    0xe79(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e27(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11bf <main+0x8f>
mov    0x2e0e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x2,%edi
jne    115f <main+0x2f>
mov    0x2ea3(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rsi),%rsi
mov    0x2e9e(%rip),%rax
mov    (%rax),%edx
call   1040 <syscall@plt>
test   %rax,%rax
jne    1176 <main+0x46>
mov    0x2e6b(%rip),%rax
jmp    1172 <main+0x42>
lea    0xe9a(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e5e(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret
lea    0xe99(%rip),%rdi
call   1050 <perror@plt>
jmp    116b <main+0x3b>

LLVM IR (-O0):
@.str = [22 x i8] c"Usage ./prog mymodule\00"
@EXIT_FAILURE = global i32 0
@__NR_delete_module = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [14 x i8] c"delete_module\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 2
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
store i32 %10, i32* %3
br label %24
11: ; preds = %2
%12 = load i32, i32* @__NR_delete_module
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = load i32, i32* @O_NONBLOCK
%17 = call i64 @syscall(i32 %12, i8* %15, i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %11
%20 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* @EXIT_FAILURE
store i32 %21, i32* %3
br label %24
22: ; preds = %11
%23 = load i32, i32* @EXIT_SUCCESS
store i32 %23, i32* %3
br label %24
24: ; preds = %22, %19, %8
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
@.str = [22 x i8] c"Usage ./prog mymodule\00"
@EXIT_FAILURE = global i32 0
@__NR_delete_module = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [14 x i8] c"delete_module\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %15
6: ; preds = %2
%7 = load i32, i32* @__NR_delete_module
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = load i32, i32* @O_NONBLOCK
%11 = tail call i64 @syscall(i32 %7, i8* %9, i32 %10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %6
%14 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %6, %13, %4
%16 = phi i32* [ @EXIT_FAILURE, %4 ], [ @EXIT_FAILURE, %13 ], [ @EXIT_SUCCESS, %6 ]
%17 = load i32, i32* %16
ret i32 %17
}