#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 */
typedef int uint8_t;

/* Variables and functions */
int /*<<< orphan*/ memcpy(char *, int *, int);
int /*<<< orphan*/ sprintf(char *, char *, int, int, int);
int /*<<< orphan*/ stm32fxx_get_devid(int *);
void stm32fxx_get_ascii_devid(char *device_id) {
  uint8_t bin_device_id[12];
  stm32fxx_get_devid(bin_device_id);
  memcpy(device_id, bin_device_id + 5, 7);
  sprintf(device_id + 7, "-%02x-%02x-%02x", bin_device_id[0], bin_device_id[2],
          bin_device_id[4]);
}


x86 assembly (clang, -O0):
<stm32fxx_get_ascii_devid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x40(%rbp),%rdi
call   1030 <stm32fxx_get_devid@plt>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
add    $0x14,%rsi
mov    $0x7,%edx
call   1040 <memcpy@plt>
mov    -0x8(%rbp),%rdi
add    $0x7,%rdi
mov    -0x40(%rbp),%edx
mov    -0x38(%rbp),%ecx
mov    -0x30(%rbp),%r8d
lea    0xe8c(%rip),%rsi
call   1050 <sprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stm32fxx_get_ascii_devid>:
push   %rbx
sub    $0x30,%rsp
mov    %rdi,%rbx
mov    %rsp,%rdi
call   1030 <stm32fxx_get_devid@plt>
lea    0x14(%rsp),%rsi
mov    %rbx,%rdi
mov    $0x7,%edx
call   1040 <memcpy@plt>
add    $0x7,%rbx
mov    (%rsp),%edx
mov    0x8(%rsp),%ecx
mov    0x10(%rsp),%r8d
lea    0xe97(%rip),%rsi
mov    %rbx,%rdi
call   1050 <sprintf@plt>
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"-%02x-%02x-%02x\00"
define void @stm32fxx_get_ascii_devid(i8* %0) {
%2 = alloca i8*
%3 = alloca [12 x i32]
store i8* %0, i8** %2
%4 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 0
%5 = call i32 @stm32fxx_get_devid(i32* %4)
%6 = load i8*, i8** %2
%7 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 0
%8 = getelementptr inbounds i32, i32* %7, i64 5
%9 = call i32 @memcpy(i8* %6, i32* %8, i32 7)
%10 = load i8*, i8** %2
%11 = getelementptr inbounds i8, i8* %10, i64 7
%12 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 0
%13 = load i32, i32* %12
%14 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 2
%15 = load i32, i32* %14
%16 = getelementptr inbounds [12 x i32], [12 x i32]* %3, i64 0, i64 4
%17 = load i32, i32* %16
%18 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %15, i32 %17)
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c"-%02x-%02x-%02x\00"
define void @stm32fxx_get_ascii_devid(i8* %0) {
%2 = alloca [12 x i32]
%3 = bitcast [12 x i32]* %2 to i8*
%4 = getelementptr inbounds [12 x i32], [12 x i32]* %2, i64 0, i64 0
%5 = call i32 @stm32fxx_get_devid(i32* %4)
%6 = getelementptr inbounds [12 x i32], [12 x i32]* %2, i64 0, i64 5
%7 = call i32 @memcpy(i8* %0, i32* %6, i32 7)
%8 = getelementptr inbounds i8, i8* %0, i64 7
%9 = load i32, i32* %4
%10 = getelementptr inbounds [12 x i32], [12 x i32]* %2, i64 0, i64 2
%11 = load i32, i32* %10
%12 = getelementptr inbounds [12 x i32], [12 x i32]* %2, i64 0, i64 4
%13 = load i32, i32* %12
%14 = call i32 @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %11, i32 %13)
ret void
}