#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 *get_tag_value(char tags[15][1024], char *tag) {
  int i = 0;
  while (i < 15) {
    if (strncmp(tags[i], tag, strlen(tag)) == 0) {
      return tags[i] + strlen(tag);
    }
    i++;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<get_tag_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0xf,-0x1c(%rbp)
jge    11bd <get_tag_value+0x9d>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
shl    $0xa,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11af <get_tag_value+0x8f>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
shl    $0xa,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    11c5 <get_tag_value+0xa5>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1137 <get_tag_value+0x17>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_tag_value>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0xf,%ebx
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     115c <get_tag_value+0x3c>
add    $0x400,%r15
add    $0xffffffffffffffff,%rbx
jne    1130 <get_tag_value+0x10>
xor    %r15d,%r15d
jmp    1169 <get_tag_value+0x49>
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
add    %rax,%r15
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @get_tag_value([1024 x i8]* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca [1024 x i8]*
%5 = alloca i8*
%6 = alloca i32
store [1024 x i8]* %0, [1024 x i8]** %4
store i8* %1, i8** %5
store i32 0, i32* %6
br label %7
7: ; preds = %31, %2
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 15
br i1 %9, label %10, label %34
10: ; preds = %7
%11 = load [1024 x i8]*, [1024 x i8]** %4
%12 = load i32, i32* %6
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %11, i64 %13
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%16 = load i8*, i8** %5
%17 = load i8*, i8** %5
%18 = call i32 @strlen(i8* %17)
%19 = call i64 @strncmp(i8* %15, i8* %16, i32 %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %31
21: ; preds = %10
%22 = load [1024 x i8]*, [1024 x i8]** %4
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %22, i64 %24
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %25, i64 0, i64 0
%27 = load i8*, i8** %5
%28 = call i32 @strlen(i8* %27)
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %26, i64 %29
store i8* %30, i8** %3
br label %35
31: ; preds = %10
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 1
store i32 %33, i32* %6
br label %7
34: ; preds = %7
store i8* null, i8** %3
br label %35
35: ; preds = %34, %21
%36 = load i8*, i8** %3
ret i8* %36
}

LLVM IR (-O2):
define i8* @get_tag_value([1024 x i8]* %0, i8* %1) {
br label %3
3: ; preds = %2, %14
%4 = phi i64 [ 0, %2 ], [ %15, %14 ]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %0, i64 %4, i64 0
%6 = tail call i32 @strlen(i8* %1)
%7 = tail call i64 @strncmp(i8* %5, i8* %1, i32 %6)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %14
9: ; preds = %3
%10 = and i64 %4, 4294967295
%11 = tail call i32 @strlen(i8* %1)
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %0, i64 %10, i64 %12
br label %17
14: ; preds = %3
%15 = add nuw nsw i64 %4, 1
%16 = icmp eq i64 %15, 15
br i1 %16, label %17, label %3
17: ; preds = %14, %9
%18 = phi i8* [ %13, %9 ], [ null, %14 ]
ret i8* %18
}