#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 strlen(char *);
scalar_t__ strncmp(char *, char *, int);
char *getarg_exact(char argv[], char key[]) {
  int l, m;
  l = strlen(key);
  m = strlen(argv);
  if ((l == m) && (strncmp(argv, key, l) == 0))
    return argv + l;
  else
    return NULL;
}


x86 assembly (clang, -O0):
<getarg_exact>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jne    1182 <getarg_exact+0x62>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1182 <getarg_exact+0x62>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    118a <getarg_exact+0x6a>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getarg_exact>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <strlen@plt>
cmp    %eax,%ebp
jne    1152 <getarg_exact+0x32>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1156 <getarg_exact+0x36>
xor    %ebx,%ebx
jmp    115c <getarg_exact+0x3c>
movslq %ebp,%rax
add    %rax,%rbx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i8* @getarg_exact(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = load i8*, i8** %5
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %6
%10 = load i8*, i8** %4
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %7
%12 = load i32, i32* %6
%13 = load i32, i32* %7
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %26
15: ; preds = %2
%16 = load i8*, i8** %4
%17 = load i8*, i8** %5
%18 = load i32, i32* %6
%19 = call i64 @strncmp(i8* %16, i8* %17, i32 %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %15
%22 = load i8*, i8** %4
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
store i8* %25, i8** %3
br label %27
26: ; preds = %15, %2
store i8* null, i8** %3
br label %27
27: ; preds = %26, %21
%28 = load i8*, i8** %3
ret i8* %28
}

LLVM IR (-O2):
define i8* @getarg_exact(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp eq i32 %3, %4
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = tail call i64 @strncmp(i8* %0, i8* %1, i32 %3)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = sext i32 %3 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
br label %12
12: ; preds = %2, %6, %9
%13 = phi i8* [ %11, %9 ], [ null, %6 ], [ null, %2 ]
ret i8* %13
}