#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 /*<<< orphan*/ strcpy(char *, char *);
void format_agp_rate(int rate, char *buf) {
  char *c = buf;
  int i;
  for (i = 0; i < 2; i++)
    if (rate & (1 << i)) {
      if (c != buf)
        *c++ = ',';
      *c++ = 'x';
      *c++ = '0' + (1 << i);
    }
  if (c != buf)
    *c = 0;
  else
    strcpy(buf, "<none>");
}


x86 assembly (clang, -O0):
<format_agp_rate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    11b7 <format_agp_rate+0xa7>
mov    -0x4(%rbp),%eax
mov    -0x1c(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     11a4 <format_agp_rate+0x94>
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
je     1172 <format_agp_rate+0x62>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x2c,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x78,(%rax)
mov    -0x1c(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
add    $0x30,%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    11a9 <format_agp_rate+0x99>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112e <format_agp_rate+0x1e>
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
je     11d1 <format_agp_rate+0xc1>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
jmp    11e1 <format_agp_rate+0xd1>
mov    -0x10(%rbp),%rdi
lea    0xe24(%rip),%rsi
call   1030 <strcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<format_agp_rate>:
mov    %rsi,%rax
test   $0x1,%dil
jne    1128 <format_agp_rate+0x18>
test   $0x2,%dil
jne    1137 <format_agp_rate+0x27>
cmp    %rsi,%rax
je     115a <format_agp_rate+0x4a>
movb   $0x0,(%rax)
ret
movw   $0x3178,(%rsi)
lea    0x2(%rsi),%rax
test   $0x2,%dil
je     111f <format_agp_rate+0xf>
mov    %rsi,%rcx
cmp    %rsi,%rax
je     1149 <format_agp_rate+0x39>
movb   $0x2c,(%rax)
add    $0x1,%rax
mov    %rax,%rcx
movw   $0x3278,(%rcx)
add    $0x2,%rcx
mov    %rcx,%rax
cmp    %rsi,%rax
jne    1124 <format_agp_rate+0x14>
lea    0xe9f(%rip),%rax
mov    %rsi,%rdi
mov    %rax,%rsi
jmp    1030 <strcpy@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"<none>\00"
define void @format_agp_rate(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
store i8* %7, i8** %5
store i32 0, i32* %6
br label %8
8: ; preds = %34, %2
%9 = load i32, i32* %6
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %37
11: ; preds = %8
%12 = load i32, i32* %3
%13 = load i32, i32* %6
%14 = shl i32 1, %13
%15 = and i32 %12, %14
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %33
17: ; preds = %11
%18 = load i8*, i8** %5
%19 = load i8*, i8** %4
%20 = icmp ne i8* %18, %19
br i1 %20, label %21, label %24
21: ; preds = %17
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %5
store i8 44, i8* %22
br label %24
24: ; preds = %21, %17
%25 = load i8*, i8** %5
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %5
store i8 120, i8* %25
%27 = load i32, i32* %6
%28 = shl i32 1, %27
%29 = add nsw i32 48, %28
%30 = trunc i32 %29 to i8
%31 = load i8*, i8** %5
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %5
store i8 %30, i8* %31
br label %33
33: ; preds = %24, %11
br label %34
34: ; preds = %33
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %8
37: ; preds = %8
%38 = load i8*, i8** %5
%39 = load i8*, i8** %4
%40 = icmp ne i8* %38, %39
br i1 %40, label %41, label %43
41: ; preds = %37
%42 = load i8*, i8** %5
store i8 0, i8* %42
br label %46
43: ; preds = %37
%44 = load i8*, i8** %4
%45 = call i32 @strcpy(i8* %44, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %46
46: ; preds = %43, %41
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"<none>\00"
define void @format_agp_rate(i32 %0, i8* %1) {
%3 = and i32 %0, 1
%4 = icmp eq i32 %3, 0
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = getelementptr inbounds i8, i8* %1, i64 1
store i8 120, i8* %1
%7 = getelementptr inbounds i8, i8* %1, i64 2
store i8 49, i8* %6
br label %8
8: ; preds = %2, %5
%9 = phi i8* [ %7, %5 ], [ %1, %2 ]
%10 = and i32 %0, 2
%11 = icmp eq i32 %10, 0
br i1 %11, label %20, label %12
12: ; preds = %8
%13 = icmp eq i8* %9, %1
br i1 %13, label %16, label %14
14: ; preds = %12
%15 = getelementptr inbounds i8, i8* %9, i64 1
store i8 44, i8* %9
br label %16
16: ; preds = %14, %12
%17 = phi i8* [ %15, %14 ], [ %1, %12 ]
%18 = getelementptr inbounds i8, i8* %17, i64 1
store i8 120, i8* %17
%19 = getelementptr inbounds i8, i8* %17, i64 2
store i8 50, i8* %18
br label %20
20: ; preds = %16, %8
%21 = phi i8* [ %19, %16 ], [ %9, %8 ]
%22 = icmp eq i8* %21, %1
br i1 %22, label %24, label %23
23: ; preds = %20
store i8 0, i8* %21
br label %26
24: ; preds = %20
%25 = tail call i32 @strcpy(i8* %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %26
26: ; preds = %24, %23
ret void
}