#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__ strcmp(char const *, char const *);
char *ttdnd_negotiate_types(const char **sourcetypes,
                            const char **targettypes) {
  const char **slist, **tlist;
  const char *s, *t;
  tlist = targettypes;
  while (t = *tlist++) {
    slist = sourcetypes;
    while (s = *slist++) {
      if (0 == strcmp(s, t)) {
        return (char *)t;
      }
    }
  }
  return (char *)targettypes[0];
}


x86 assembly (clang, -O0):
<ttdnd_negotiate_types>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x28(%rbp)
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
je     11a2 <ttdnd_negotiate_types+0x92>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     119d <ttdnd_negotiate_types+0x8d>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1030 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    1198 <ttdnd_negotiate_types+0x88>
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ad <ttdnd_negotiate_types+0x9d>
jmp    1150 <ttdnd_negotiate_types+0x40>
jmp    1128 <ttdnd_negotiate_types+0x18>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ttdnd_negotiate_types>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    (%rsi),%r13
test   %r13,%r13
je     116e <ttdnd_negotiate_types+0x5e>
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsi,%r12
add    $0x8,%r12
mov    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%rbx),%rdi
test   %rdi,%rdi
je     1160 <ttdnd_negotiate_types+0x50>
add    $0x8,%rbx
mov    %r13,%rsi
call   1030 <strcmp@plt>
test   %rax,%rax
jne    1140 <ttdnd_negotiate_types+0x30>
jmp    1171 <ttdnd_negotiate_types+0x61>
nopl   0x0(%rax,%rax,1)
mov    (%r12),%r13
test   %r13,%r13
jne    112a <ttdnd_negotiate_types+0x1a>
mov    (%r14),%r13
jmp    1171 <ttdnd_negotiate_types+0x61>
xor    %r13d,%r13d
mov    %r13,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i8* @ttdnd_negotiate_types(i8** nocapture %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = icmp eq i8* %3, null
br i1 %4, label %22, label %8
5: ; preds = %12
%6 = load i8*, i8** %11
%7 = icmp eq i8* %6, null
br i1 %7, label %20, label %8
8: ; preds = %2, %5
%9 = phi i8* [ %6, %5 ], [ %3, %2 ]
%10 = phi i8** [ %11, %5 ], [ %1, %2 ]
%11 = getelementptr inbounds i8*, i8** %10, i64 1
br label %12
12: ; preds = %8, %16
%13 = phi i8** [ %17, %16 ], [ %0, %8 ]
%14 = load i8*, i8** %13
%15 = icmp eq i8* %14, null
br i1 %15, label %5, label %16
16: ; preds = %12
%17 = getelementptr inbounds i8*, i8** %13, i64 1
%18 = tail call i64 @strcmp(i8* %14, i8* %9)
%19 = icmp eq i64 %18, 0
br i1 %19, label %22, label %12
20: ; preds = %5
%21 = load i8*, i8** %1
br label %22
22: ; preds = %16, %2, %20
%23 = phi i8* [ %21, %20 ], [ null, %2 ], [ %9, %16 ]
ret i8* %23
}