#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*/ ssid;

/* Variables and functions */
int /*<<< orphan*/ free(char const *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, int, ...);
char const *q;
int sscanf(char *, char *, int *, int *);
int main() {
  char ssid[10][32];
  int unit, bss;
  char *p = malloc(100);
  const char *q = q;
  free(q);
  unit = bss = 8;
  int ret = sscanf("tf.1", "%*[^0-9]%d.%d", &unit, &bss);
  printf("ret = %d, unit = %d, bss = %d \n", ret, unit, bss);
  unit = bss = 8;
  ret = sscanf("tf2.3", "%*[^0-9]%d.%d", &unit, &bss);
  printf("ret = %d, unit = %d, bss = %d\n", ret, unit, bss);
  printf("sizeof(ssid) = %d\n", sizeof(ssid));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x64,%edi
call   1050 <malloc@plt>
mov    %rax,-0x160(%rbp)
mov    -0x168(%rbp),%rax
mov    %rax,-0x168(%rbp)
mov    -0x168(%rbp),%rdi
call   1030 <free@plt>
movl   $0x8,-0x158(%rbp)
movl   $0x8,-0x154(%rbp)
lea    0xe68(%rip),%rdi
lea    0xe66(%rip),%rsi
lea    -0x154(%rbp),%rdx
lea    -0x158(%rbp),%rcx
call   1060 <sscanf@plt>
mov    %eax,-0x16c(%rbp)
mov    -0x16c(%rbp),%esi
mov    -0x154(%rbp),%edx
mov    -0x158(%rbp),%ecx
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x8,-0x158(%rbp)
movl   $0x8,-0x154(%rbp)
lea    0xe40(%rip),%rdi
lea    0xe0b(%rip),%rsi
lea    -0x154(%rbp),%rdx
lea    -0x158(%rbp),%rcx
call   1060 <sscanf@plt>
mov    %eax,-0x16c(%rbp)
mov    -0x16c(%rbp),%esi
mov    -0x154(%rbp),%edx
mov    -0x158(%rbp),%ecx
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe1e(%rip),%rdi
mov    $0x140,%esi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x170,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
call   1030 <free@plt>
movl   $0x8,0x8(%rsp)
movl   $0x8,0xc(%rsp)
lea    0xeab(%rip),%rdi
lea    0xea9(%rip),%rbx
lea    0xc(%rsp),%r14
lea    0x8(%rsp),%r15
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
call   1050 <sscanf@plt>
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    0xe90(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x8,0x8(%rsp)
movl   $0x8,0xc(%rsp)
lea    0xe90(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r15,%rcx
call   1050 <sscanf@plt>
mov    0xc(%rsp),%edx
mov    0x8(%rsp),%ecx
lea    0xe79(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe88(%rip),%rdi
mov    $0x140,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"tf.1\00"
@.str.1 = [14 x i8] c"%*[^0-9]%d.%d\00"
@.str.2 = [32 x i8] c"ret = %d, unit = %d, bss = %d \0A\00"
@.str.3 = [6 x i8] c"tf2.3\00"
@.str.4 = [31 x i8] c"ret = %d, unit = %d, bss = %d\0A\00"
@.str.5 = [19 x i8] c"sizeof(ssid) = %d\0A\00"
@q = global i8* null
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x [32 x i8]]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %1
%8 = call i8* @malloc(i32 100)
store i8* %8, i8** %5
%9 = load i8*, i8** %6
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = call i32 @free(i8* %10)
store i32 8, i32* %4
store i32 8, i32* %3
%12 = call i32 @sscanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
store i32 %12, i32* %7
%13 = load i32, i32* %7
%14 = load i32, i32* %3
%15 = load i32, i32* %4
%16 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %13, i32 %14, i32 %15)
store i32 8, i32* %4
store i32 8, i32* %3
%17 = call i32 @sscanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
store i32 %17, i32* %7
%18 = load i32, i32* %7
%19 = load i32, i32* %3
%20 = load i32, i32* %4
%21 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %18, i32 %19, i32 %20)
%22 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 320)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"tf.1\00"
@.str.1 = [14 x i8] c"%*[^0-9]%d.%d\00"
@.str.2 = [32 x i8] c"ret = %d, unit = %d, bss = %d \0A\00"
@.str.3 = [6 x i8] c"tf2.3\00"
@.str.4 = [31 x i8] c"ret = %d, unit = %d, bss = %d\0A\00"
@.str.5 = [19 x i8] c"sizeof(ssid) = %d\0A\00"
@q = global i8* null
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @free(i8* undef)
store i32 8, i32* %2
store i32 8, i32* %1
%6 = call i32 @sscanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%7 = load i32, i32* %1
%8 = load i32, i32* %2
%9 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %6, i32 %7, i32 %8)
store i32 8, i32* %2
store i32 8, i32* %1
%10 = call i32 @sscanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%11 = load i32, i32* %1
%12 = load i32, i32* %2
%13 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %10, i32 %11, i32 %12)
%14 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 320)
ret i32 0
}