#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 */
float atof(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
char *strstr(char *, char *);
int find_arg_float(int argc, char **argv, char *name, float *val, int opc) {
  int i = 0;
  int log = 0;
  char *teste = NULL;
  int len;
  strcat(name, "=");
  while (i < argc && log == 0) {
    teste = strstr(argv[i], name);
    if (teste != NULL) {
      len = strlen(name);
      val[0] = atof(teste + len);
      log = 1;
      return 0;
    }
    ++i;
  }
  if (opc) {
    val[0] = 0.0;
    return 2;
  } else {
    fprintf(stderr,
            "#############################################################\n");
    fprintf(stderr, "==> Parameter not set: %s \n", name);
    fprintf(stderr,
            "#############################################################\n");
    return 1;
  }
}


x86 assembly (clang, -O0):
<find_arg_float>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe74(%rip),%rsi
call   1060 <strcat@plt>
mov    -0x28(%rbp),%ecx
xor    %eax,%eax
cmp    -0x8(%rbp),%ecx
mov    %al,-0x3d(%rbp)
jge    11ac <find_arg_float+0x5c>
cmpl   $0x0,-0x2c(%rbp)
sete   %al
mov    %al,-0x3d(%rbp)
mov    -0x3d(%rbp),%al
test   $0x1,%al
jne    11bc <find_arg_float+0x6c>
jmp    1225 <find_arg_float+0xd5>
mov    -0x10(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <strstr@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1217 <find_arg_float+0xc7>
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%rdi
movslq -0x3c(%rbp),%rax
add    %rax,%rdi
call   1030 <atof@plt>
mov    -0x20(%rbp),%rax
movss  %xmm0,(%rax)
movl   $0x1,-0x2c(%rbp)
movl   $0x0,-0x4(%rbp)
jmp    1296 <find_arg_float+0x146>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1191 <find_arg_float+0x41>
cmpl   $0x0,-0x24(%rbp)
je     1246 <find_arg_float+0xf6>
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movss  %xmm0,(%rax)
movl   $0x2,-0x4(%rbp)
jmp    1296 <find_arg_float+0x146>
mov    0x2d93(%rip),%rax
mov    (%rax),%edi
lea    0xdac(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d7c(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
lea    0xdd0(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2d61(%rip),%rax
mov    (%rax),%edi
lea    0xd7a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_arg_float>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r15d
mov    %rcx,(%rsp)
mov    %rdx,%r12
mov    %rsi,%r13
mov    %edi,%ebx
lea    0xe8f(%rip),%rsi
mov    %rdx,%rdi
call   1060 <strcat@plt>
test   %ebx,%ebx
jle    11ab <find_arg_float+0x5b>
mov    %ebx,%ebp
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x0(%r13,%r14,8),%rdi
mov    %r12,%rsi
call   1070 <strstr@plt>
test   %rax,%rax
jne    11c1 <find_arg_float+0x71>
add    $0x1,%r14
cmp    %r14,%rbp
jne    1190 <find_arg_float+0x40>
test   %r15d,%r15d
je     11e5 <find_arg_float+0x95>
mov    (%rsp),%rax
movl   $0x0,(%rax)
mov    $0x2,%eax
jmp    1226 <find_arg_float+0xd6>
mov    %rax,%rbx
mov    %r12,%rdi
call   1040 <strlen@plt>
cltq
add    %rax,%rbx
mov    %rbx,%rdi
call   1030 <atof@plt>
mov    (%rsp),%rax
movss  %xmm0,(%rax)
xor    %eax,%eax
jmp    1226 <find_arg_float+0xd6>
mov    0x2df4(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xe0c(%rip),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xe37(%rip),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"=\00"
@stderr = global i32 0
@.str.1 = [63 x i8] c"#############################################################\0A\00"
@.str.2 = [28 x i8] c"==> Parameter not set: %s \0A\00"
define i32 @find_arg_float(i32 %0, i8** %1, i8* %2, float* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8**
%9 = alloca i8*
%10 = alloca float*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i32
store i32 %0, i32* %7
store i8** %1, i8*** %8
store i8* %2, i8** %9
store float* %3, float** %10
store i32 %4, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
store i8* null, i8** %14
%16 = load i8*, i8** %9
%17 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %47, %5
%19 = load i32, i32* %12
%20 = load i32, i32* %7
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i32, i32* %13
%24 = icmp eq i32 %23, 0
br label %25
25: ; preds = %22, %18
%26 = phi i1 [ false, %18 ], [ %24, %22 ]
br i1 %26, label %27, label %50
27: ; preds = %25
%28 = load i8**, i8*** %8
%29 = load i32, i32* %12
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %28, i64 %30
%32 = load i8*, i8** %31
%33 = load i8*, i8** %9
%34 = call i8* @strstr(i8* %32, i8* %33)
store i8* %34, i8** %14
%35 = load i8*, i8** %14
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %47
37: ; preds = %27
%38 = load i8*, i8** %9
%39 = call i32 @strlen(i8* %38)
store i32 %39, i32* %15
%40 = load i8*, i8** %14
%41 = load i32, i32* %15
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = call float @atof(i8* %43)
%45 = load float*, float** %10
%46 = getelementptr inbounds float, float* %45, i64 0
store float %44, float* %46
store i32 1, i32* %13
store i32 0, i32* %6
br label %64
47: ; preds = %27
%48 = load i32, i32* %12
%49 = add nsw i32 %48, 1
store i32 %49, i32* %12
br label %18
50: ; preds = %25
%51 = load i32, i32* %11
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %50
%54 = load float*, float** %10
%55 = getelementptr inbounds float, float* %54, i64 0
store float 0.000000e+00, float* %55
store i32 2, i32* %6
br label %64
56: ; preds = %50
%57 = load i32, i32* @stderr
%58 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0))
%59 = load i32, i32* @stderr
%60 = load i8*, i8** %9
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %60)
%62 = load i32, i32* @stderr
%63 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %6
br label %64
64: ; preds = %56, %53, %37
%65 = load i32, i32* %6
ret i32 %65
}

LLVM IR (-O2):
@.str = [2 x i8] c"=\00"
@stderr = global i32 0
@.str.1 = [63 x i8] c"#############################################################\0A\00"
@.str.2 = [28 x i8] c"==> Parameter not set: %s \0A\00"
define i32 @find_arg_float(i32 %0, i8** nocapture %1, i8* %2, float* nocapture writeonly %3, i32 %4) {
%6 = tail call i32 @strcat(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %24
8: ; preds = %5
%9 = zext i32 %0 to i64
br label %12
10: ; preds = %12
%11 = icmp eq i64 %18, %9
br i1 %11, label %24, label %12
12: ; preds = %8, %10
%13 = phi i64 [ 0, %8 ], [ %18, %10 ]
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
%15 = load i8*, i8** %14
%16 = tail call i8* @strstr(i8* dereferenceable(1) %15, i8* dereferenceable(1) %2)
%17 = icmp eq i8* %16, null
%18 = add nuw nsw i64 %13, 1
br i1 %17, label %10, label %19
19: ; preds = %12
%20 = tail call i32 @strlen(i8* %2)
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %16, i64 %21
%23 = tail call float @atof(i8* %22)
store float %23, float* %3
br label %34
24: ; preds = %10, %5
%25 = icmp eq i32 %4, 0
br i1 %25, label %27, label %26
26: ; preds = %24
store float 0.000000e+00, float* %3
br label %34
27: ; preds = %24
%28 = load i32, i32* @stderr
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0))
%30 = load i32, i32* @stderr
%31 = tail call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%32 = load i32, i32* @stderr
%33 = tail call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.1, i64 0, i64 0))
br label %34
34: ; preds = %27, %26, %19
%35 = phi i32 [ 0, %19 ], [ 2, %26 ], [ 1, %27 ]
ret i32 %35
}