#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 */
char *strchr(char *, char);
char toupper(unsigned char);
char *trimwhitespace(char *);
void split(char *buf, char **key, char **val) {
  char *p = strchr(buf, '=');
  if (p == NULL) {
    return;
  }
  *p = '\0';
  *key = trimwhitespace(buf);
  char *tmp = *key;
  while (*tmp) {
    *tmp = toupper((unsigned char)*tmp);
    tmp++;
  }
  p++;
  *val = trimwhitespace(p);
}


x86 assembly (clang, -O0):
<split>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x3d,%esi
call   1040 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1166 <split+0x36>
jmp    11dc <split+0xac>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
call   1050 <trimwhitespace@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
je     11bd <split+0x8d>
mov    -0x28(%rbp),%rax
movzbl (%rax),%edi
call   1030 <toupper@plt>
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %cl,(%rax)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    118b <split+0x5b>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <trimwhitespace@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<split>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%rbx
mov    $0x3d,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1195 <split+0x65>
mov    %rax,%r15
movb   $0x0,(%rax)
mov    %rbx,%rdi
call   1050 <trimwhitespace@plt>
mov    %rax,%rbx
mov    %rax,(%r12)
mov    (%rax),%al
test   %al,%al
je     1186 <split+0x56>
add    $0x1,%rbx
nop
movzbl %al,%edi
call   1030 <toupper@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1170 <split+0x40>
add    $0x1,%r15
mov    %r15,%rdi
call   1050 <trimwhitespace@plt>
mov    %rax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @split(i8* %0, i8** nocapture writeonly %1, i8** nocapture writeonly %2) {
%4 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 61)
%5 = icmp eq i8* %4, null
br i1 %5, label %20, label %6
6: ; preds = %3
store i8 0, i8* %4
%7 = tail call i8* @trimwhitespace(i8* %0)
store i8* %7, i8** %1
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %6, %10
%11 = phi i8 [ %15, %10 ], [ %8, %6 ]
%12 = phi i8* [ %14, %10 ], [ %7, %6 ]
%13 = tail call signext i8 @toupper(i8 zeroext %11)
store i8 %13, i8* %12
%14 = getelementptr inbounds i8, i8* %12, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %10
17: ; preds = %10, %6
%18 = getelementptr inbounds i8, i8* %4, i64 1
%19 = tail call i8* @trimwhitespace(i8* %18)
store i8* %19, i8** %2
br label %20
20: ; preds = %3, %17
ret void
}