#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 /*<<< orphan*/ url;
typedef int /*<<< orphan*/ cmd;

/* Variables and functions */
scalar_t__ snprintf(char *, int, char *, ...);
int /*<<< orphan*/ system(char *);
void check_for_updates(unsigned short btn_version, const char *version,
                       const char *serial, const char *id) {
  char url[512];
  if (snprintf(url, sizeof(url),
               "https://blokas.io/pisound/"
               "/updates?btnv=%x.%02x&v=%s&sn=%s&id=%s",
               (btn_version & 0xff00) >> 8, btn_version & 0xff, version, serial,
               id) < 0)
    return;
  char cmd[1024];
  if (snprintf(cmd, sizeof(cmd),
               "sleep 30 && wget \"%s\" -O - > /dev/null 2>&1 &", url) < 0)
    return;
  system(cmd);
}


x86 assembly (clang, -O0):
<check_for_updates>:
push   %rbp
mov    %rsp,%rbp
sub    $0x630,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x220(%rbp),%rdi
movzwl -0x2(%rbp),%ecx
and    $0xff00,%ecx
sar    $0x8,%ecx
movzwl -0x2(%rbp),%r8d
and    $0xff,%r8d
mov    -0x10(%rbp),%r9
mov    -0x18(%rbp),%r10
mov    -0x20(%rbp),%rax
mov    $0x200,%esi
lea    0xe8a(%rip),%rdx
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1040 <snprintf@plt>
cmp    $0x0,%rax
jge    1195 <check_for_updates+0x75>
jmp    11d1 <check_for_updates+0xb1>
lea    -0x620(%rbp),%rdi
lea    -0x220(%rbp),%rcx
mov    $0x400,%esi
lea    0xe92(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
cmp    $0x0,%rax
jge    11c5 <check_for_updates+0xa5>
jmp    11d1 <check_for_updates+0xb1>
lea    -0x620(%rbp),%rdi
call   1030 <system@plt>
add    $0x630,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_for_updates>:
sub    $0x608,%rsp
mov    %rcx,%r10
mov    %rdx,%r11
mov    %rsi,%r9
movzbl %dil,%r8d
mov    %edi,%ecx
shr    $0x8,%ecx
lea    0xec0(%rip),%rdx
mov    %rsp,%rdi
mov    $0x200,%esi
xor    %eax,%eax
push   %r10
push   %r11
call   1040 <snprintf@plt>
add    $0x10,%rsp
test   %rax,%rax
js     118c <check_for_updates+0x6c>
lea    0xede(%rip),%rdx
lea    0x200(%rsp),%rdi
mov    %rsp,%rcx
mov    $0x400,%esi
xor    %eax,%eax
call   1040 <snprintf@plt>
test   %rax,%rax
js     118c <check_for_updates+0x6c>
lea    0x200(%rsp),%rdi
call   1030 <system@plt>
add    $0x608,%rsp
ret

LLVM IR (-O0):
@.str = [65 x i8] c"https://blokas.io/pisound//updates?btnv=%x.%02x&v=%s&sn=%s&id=%s\00"
@.str.1 = [46 x i8] c"sleep 30 && wget \22%s\22 -O - > /dev/null 2>&1 &\00"
define void @check_for_updates(i16 zeroext %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i16
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [512 x i8]
%10 = alloca [1024 x i8]
store i16 %0, i16* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%12 = load i16, i16* %5
%13 = zext i16 %12 to i32
%14 = and i32 %13, 65280
%15 = ashr i32 %14, 8
%16 = load i16, i16* %5
%17 = zext i16 %16 to i32
%18 = and i32 %17, 255
%19 = load i8*, i8** %6
%20 = load i8*, i8** %7
%21 = load i8*, i8** %8
%22 = call i64 (i8*, i32, i8*, ...) @snprintf(i8* %11, i32 512, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %18, i8* %19, i8* %20, i8* %21)
%23 = icmp slt i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %4
br label %34
25: ; preds = %4
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%27 = getelementptr inbounds [512 x i8], [512 x i8]* %9, i64 0, i64 0
%28 = call i64 (i8*, i32, i8*, ...) @snprintf(i8* %26, i32 1024, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%29 = icmp slt i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %25
br label %34
31: ; preds = %25
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%33 = call i32 @system(i8* %32)
br label %34
34: ; preds = %31, %30, %24
ret void
}

LLVM IR (-O2):
@.str = [65 x i8] c"https://blokas.io/pisound//updates?btnv=%x.%02x&v=%s&sn=%s&id=%s\00"
@.str.1 = [46 x i8] c"sleep 30 && wget \22%s\22 -O - > /dev/null 2>&1 &\00"
define void @check_for_updates(i16 zeroext %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca [512 x i8]
%6 = alloca [1024 x i8]
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%8 = zext i16 %0 to i32
%9 = lshr i32 %8, 8
%10 = and i32 %8, 255
%11 = call i64 (i8*, i32, i8*, ...) @snprintf(i8* %7, i32 512, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %10, i8* %1, i8* %2, i8* %3)
%12 = icmp slt i64 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %4
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%15 = call i64 (i8*, i32, i8*, ...) @snprintf(i8* %14, i32 1024, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%16 = icmp slt i64 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %13
%18 = call i32 @system(i8* %14)
br label %19
19: ; preds = %13, %17
br label %20
20: ; preds = %4, %19
ret void
}