#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 */
struct utsname {
  char *sysname;
  int /*<<< orphan*/ machine;
};

/* Variables and functions */
int /*<<< orphan*/ strcmp(int /*<<< orphan*/, char *);
int /*<<< orphan*/ strcpy(int /*<<< orphan*/, char *);
char tolower(char);
void filter_unam(struct utsname *unam) {
  char *p;
  if (!strcmp(unam->machine, "amd64"))
    strcpy(unam->machine, "x86_64");
  if (!strcmp(unam->machine, "i686"))
    strcpy(unam->machine, "i386");
  for (p = unam->sysname; *p; p++)
    *p = tolower(*p);
}


x86 assembly (clang, -O0):
<filter_unam>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edi
lea    0xeb6(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    116b <filter_unam+0x3b>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edi
lea    0xea0(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edi
lea    0xe94(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    119a <filter_unam+0x6a>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edi
lea    0xe7d(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11d7 <filter_unam+0xa7>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1050 <tolower@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11a5 <filter_unam+0x75>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filter_unam>:
push   %rbx
mov    %rdi,%rbx
mov    0x8(%rdi),%edi
lea    0xec2(%rip),%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    1156 <filter_unam+0x26>
mov    0x8(%rbx),%edi
lea    0xeb5(%rip),%rsi
call   1030 <strcpy@plt>
mov    0x8(%rbx),%edi
lea    0xead(%rip),%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    1178 <filter_unam+0x48>
mov    0x8(%rbx),%edi
lea    0xe9f(%rip),%rsi
call   1030 <strcpy@plt>
mov    (%rbx),%rbx
mov    (%rbx),%al
test   %al,%al
je     11a6 <filter_unam+0x76>
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %al,%edi
call   1050 <tolower@plt>
mov    %al,-0x1(%rbx)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1190 <filter_unam+0x60>
pop    %rbx
ret

LLVM IR (-O0):
%struct.utsname = type { i8*, i32 }
@.str = [6 x i8] c"amd64\00"
@.str.1 = [7 x i8] c"x86_64\00"
@.str.2 = [5 x i8] c"i686\00"
@.str.3 = [5 x i8] c"i386\00"
define void @filter_unam(%struct.utsname* %0) {
%2 = alloca %struct.utsname*
%3 = alloca i8*
store %struct.utsname* %0, %struct.utsname** %2
%4 = load %struct.utsname*, %struct.utsname** %2
%5 = getelementptr inbounds %struct.utsname, %struct.utsname* %4, i32 0, i32 1
%6 = load i32, i32* %5
%7 = call i32 @strcmp(i32 %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i32 %7, 0
br i1 %8, label %14, label %9
9: ; preds = %1
%10 = load %struct.utsname*, %struct.utsname** %2
%11 = getelementptr inbounds %struct.utsname, %struct.utsname* %10, i32 0, i32 1
%12 = load i32, i32* %11
%13 = call i32 @strcpy(i32 %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %9, %1
%15 = load %struct.utsname*, %struct.utsname** %2
%16 = getelementptr inbounds %struct.utsname, %struct.utsname* %15, i32 0, i32 1
%17 = load i32, i32* %16
%18 = call i32 @strcmp(i32 %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp ne i32 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %14
%21 = load %struct.utsname*, %struct.utsname** %2
%22 = getelementptr inbounds %struct.utsname, %struct.utsname* %21, i32 0, i32 1
%23 = load i32, i32* %22
%24 = call i32 @strcpy(i32 %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %25
25: ; preds = %20, %14
%26 = load %struct.utsname*, %struct.utsname** %2
%27 = getelementptr inbounds %struct.utsname, %struct.utsname* %26, i32 0, i32 0
%28 = load i8*, i8** %27
store i8* %28, i8** %3
br label %29
29: ; preds = %38, %25
%30 = load i8*, i8** %3
%31 = load i8, i8* %30
%32 = icmp ne i8 %31, 0
br i1 %32, label %33, label %41
33: ; preds = %29
%34 = load i8*, i8** %3
%35 = load i8, i8* %34
%36 = call signext i8 @tolower(i8 signext %35)
%37 = load i8*, i8** %3
store i8 %36, i8* %37
br label %38
38: ; preds = %33
%39 = load i8*, i8** %3
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %3
br label %29
41: ; preds = %29
ret void
}

LLVM IR (-O2):
%struct.utsname = type { i8*, i32 }
@.str = [6 x i8] c"amd64\00"
@.str.1 = [7 x i8] c"x86_64\00"
@.str.2 = [5 x i8] c"i686\00"
@.str.3 = [5 x i8] c"i386\00"
define void @filter_unam(%struct.utsname* nocapture %0) {
%2 = getelementptr inbounds %struct.utsname, %struct.utsname* %0, i64 0, i32 1
%3 = load i32, i32* %2
%4 = tail call i32 @strcmp(i32 %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i32, i32* %2
%8 = tail call i32 @strcpy(i32 %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %9
9: ; preds = %6, %1
%10 = load i32, i32* %2
%11 = tail call i32 @strcmp(i32 %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %9
%14 = load i32, i32* %2
%15 = tail call i32 @strcpy(i32 %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %16
16: ; preds = %13, %9
%17 = getelementptr inbounds %struct.utsname, %struct.utsname* %0, i64 0, i32 0
%18 = load i8*, i8** %17
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %28, label %21
21: ; preds = %16, %21
%22 = phi i8 [ %26, %21 ], [ %19, %16 ]
%23 = phi i8* [ %25, %21 ], [ %18, %16 ]
%24 = tail call signext i8 @tolower(i8 signext %22)
store i8 %24, i8* %23
%25 = getelementptr inbounds i8, i8* %23, i64 1
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 0
br i1 %27, label %28, label %21
28: ; preds = %21, %16
ret void
}