#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__ geteuid();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ show_instr(char *);
int /*<<< orphan*/ strcmp(char *, char *);
int test_args(int argc, char *argv[]) {
  int modo;
  if (argc < 3) {
    show_instr(argv[0]);
    return (-1);
  }
  if (!strcmp(argv[1], "-icmp"))
    modo = 1;
  else if (!strcmp(argv[1], "-tcp"))
    modo = 2;
  else {
    show_instr(argv[0]);
    return (-1);
  }
  if ((modo == 1) && geteuid()) {
    printf("\nNecesitas ser root (para usar raw sockets).\n\n");
    return (-1);
  }
  if ((modo == 2) && (argc < 4)) {
    show_instr(argv[0]);
    return (-1);
  }
  return (modo);
}


x86 assembly (clang, -O0):
<test_args>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1171 <test_args+0x31>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <show_instr@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1245 <test_args+0x105>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe80(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    119a <test_args+0x5a>
movl   $0x1,-0x14(%rbp)
jmp    11e0 <test_args+0xa0>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe5d(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11c3 <test_args+0x83>
movl   $0x2,-0x14(%rbp)
jmp    11db <test_args+0x9b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <show_instr@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1245 <test_args+0x105>
jmp    11e0 <test_args+0xa0>
cmpl   $0x1,-0x14(%rbp)
jne    1213 <test_args+0xd3>
mov    $0x0,%al
call   1040 <geteuid@plt>
cmp    $0x0,%rax
je     1213 <test_args+0xd3>
lea    0xe09(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1245 <test_args+0x105>
cmpl   $0x2,-0x14(%rbp)
jne    123f <test_args+0xff>
cmpl   $0x4,-0x8(%rbp)
jge    123f <test_args+0xff>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <show_instr@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1245 <test_args+0x105>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_args>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
cmp    $0x2,%edi
jle    1182 <test_args+0x42>
mov    %edi,%ebp
mov    0x8(%rbx),%r14
lea    0xea7(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
je     1194 <test_args+0x54>
lea    0xe9a(%rip),%rsi
mov    %r14,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
jne    1182 <test_args+0x42>
mov    $0x2,%eax
cmp    $0x3,%ebp
ja     118f <test_args+0x4f>
mov    (%rbx),%rdi
call   1060 <show_instr@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %eax,%eax
call   1040 <geteuid@plt>
test   %rax,%rax
je     11ae <test_args+0x6e>
lea    0xe64(%rip),%rdi
call   1030 <puts@plt>
jmp    118a <test_args+0x4a>
mov    $0x1,%eax
jmp    118f <test_args+0x4f>

LLVM IR (-O0):
@.str = [6 x i8] c"-icmp\00"
@.str.1 = [5 x i8] c"-tcp\00"
@.str.2 = [47 x i8] c"\0ANecesitas ser root (para usar raw sockets).\0A\0A\00"
define i32 @test_args(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 3
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
%13 = call i32 @show_instr(i8* %12)
store i32 -1, i32* %3
br label %55
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @strcmp(i8* %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%19 = icmp ne i32 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %14
store i32 1, i32* %6
br label %34
21: ; preds = %14
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @strcmp(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %21
store i32 2, i32* %6
br label %33
28: ; preds = %21
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 0
%31 = load i8*, i8** %30
%32 = call i32 @show_instr(i8* %31)
store i32 -1, i32* %3
br label %55
33: ; preds = %27
br label %34
34: ; preds = %33, %20
%35 = load i32, i32* %6
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %42
37: ; preds = %34
%38 = call i64 (...) @geteuid()
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %3
br label %55
42: ; preds = %37, %34
%43 = load i32, i32* %6
%44 = icmp eq i32 %43, 2
br i1 %44, label %45, label %53
45: ; preds = %42
%46 = load i32, i32* %4
%47 = icmp slt i32 %46, 4
br i1 %47, label %48, label %53
48: ; preds = %45
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 0
%51 = load i8*, i8** %50
%52 = call i32 @show_instr(i8* %51)
store i32 -1, i32* %3
br label %55
53: ; preds = %45, %42
%54 = load i32, i32* %6
store i32 %54, i32* %3
br label %55
55: ; preds = %53, %48, %40, %28, %9
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@.str = [6 x i8] c"-icmp\00"
@.str.1 = [5 x i8] c"-tcp\00"
@str = [46 x i8] c"\0ANecesitas ser root (para usar raw sockets).\0A\00"
define i32 @test_args(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @show_instr(i8* %5)
br label %28
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %9, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %7
%13 = tail call i32 @strcmp(i8* dereferenceable(1) %9, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %23, label %15
15: ; preds = %12
%16 = load i8*, i8** %1
%17 = tail call i32 @show_instr(i8* %16)
br label %28
18: ; preds = %7
%19 = tail call i64 (...) @geteuid()
%20 = icmp eq i64 %19, 0
br i1 %20, label %28, label %21
21: ; preds = %18
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
br label %28
23: ; preds = %12
%24 = icmp ugt i32 %0, 3
br i1 %24, label %28, label %25
25: ; preds = %23
%26 = load i8*, i8** %1
%27 = tail call i32 @show_instr(i8* %26)
br label %28
28: ; preds = %18, %23, %25, %21, %15, %4
%29 = phi i32 [ -1, %4 ], [ -1, %15 ], [ -1, %21 ], [ -1, %25 ], [ 2, %23 ], [ 1, %18 ]
ret i32 %29
}