#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*/ sprintf(char *, char *, int, int);
int strlen(char *);
char *SPIName(char *buff, int SPI_Dev, int SPI_Port) {
  int dvlen __attribute__((unused)) = strlen("/dev/spidev");
  if (SPI_Dev < 0 && SPI_Dev > 9)
    return NULL;
  if (SPI_Port < 0 && SPI_Port > 9)
    return NULL;
  sprintf(buff, "/dev/spidev%01d.%01d", SPI_Dev, SPI_Port);
  return buff;
}


x86 assembly (clang, -O0):
<SPIName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
lea    0xec7(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1162 <SPIName+0x42>
cmpl   $0x9,-0x14(%rbp)
jle    1162 <SPIName+0x42>
movq   $0x0,-0x8(%rbp)
jmp    11a1 <SPIName+0x81>
cmpl   $0x0,-0x18(%rbp)
jge    1183 <SPIName+0x63>
cmpl   $0x9,-0x18(%rbp)
jle    1183 <SPIName+0x63>
movq   $0x0,-0x8(%rbp)
jmp    11a1 <SPIName+0x81>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xe78(%rip),%rsi
call   1040 <sprintf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SPIName>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xecd(%rip),%rdi
call   1030 <strlen@plt>
lea    0xecd(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
mov    %r14d,%ecx
call   1040 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"/dev/spidev\00"
@.str.1 = [21 x i8] c"/dev/spidev%01d.%01d\00"
define i8* @SPIName(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%9 = call i32 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 %9, i32* %8
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %3
%13 = load i32, i32* %6
%14 = icmp sgt i32 %13, 9
br i1 %14, label %15, label %16
15: ; preds = %12
store i8* null, i8** %4
br label %29
16: ; preds = %12, %3
%17 = load i32, i32* %7
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i32, i32* %7
%21 = icmp sgt i32 %20, 9
br i1 %21, label %22, label %23
22: ; preds = %19
store i8* null, i8** %4
br label %29
23: ; preds = %19, %16
%24 = load i8*, i8** %5
%25 = load i32, i32* %6
%26 = load i32, i32* %7
%27 = call i32 @sprintf(i8* %24, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %25, i32 %26)
%28 = load i8*, i8** %5
store i8* %28, i8** %4
br label %29
29: ; preds = %23, %22, %15
%30 = load i8*, i8** %4
ret i8* %30
}

LLVM IR (-O2):
@.str = [12 x i8] c"/dev/spidev\00"
@.str.1 = [21 x i8] c"/dev/spidev%01d.%01d\00"
define i8* @SPIName(i8* returned writeonly %0, i32 %1, i32 %2) {
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 %2)
ret i8* %0
}